Initial commit
This commit is contained in:
31
src/Struct/addField.c
Normal file
31
src/Struct/addField.c
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "../../include/ground.h"
|
||||
|
||||
void _GroundStructAddField(GroundStruct* gs, const char* id, GroundValue value) {
|
||||
GroundObjectField* field;
|
||||
HASH_FIND_STR(gs->fields, id, field);
|
||||
|
||||
if (field != NULL) {
|
||||
Ground.Free.Value(field->value);
|
||||
*field->value = Ground.Copy.Value(&value);
|
||||
|
||||
strncpy(field->name, id, 2047);
|
||||
} else {
|
||||
field = malloc(sizeof(GroundObjectField));
|
||||
|
||||
if (field == NULL) {
|
||||
Ground.Flags.error = true;
|
||||
return;
|
||||
}
|
||||
|
||||
field->value = malloc(sizeof(GroundValue));
|
||||
if (field->value == NULL) {
|
||||
Ground.Flags.error = true;
|
||||
return;
|
||||
}
|
||||
|
||||
*field->value = Ground.Copy.Value(&value);
|
||||
strncpy(field->name, id, 2047);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user