in lib/parson.c [553:587]
static JSON_Status json_object_add(JSON_Object *object, char *name, JSON_Value *value) {
unsigned long hash = 0;
parson_bool_t found = PARSON_FALSE;
size_t cell_ix = 0;
JSON_Status res = JSONFailure;
if (!object || !name || !value) {
return JSONFailure;
}
hash = hash_string(name, strlen(name));
found = PARSON_FALSE;
cell_ix = json_object_get_cell_ix(object, name, strlen(name), hash, &found);
if (found) {
return JSONFailure;
}
if (object->count >= object->item_capacity) {
res = json_object_grow_and_rehash(object);
if (res != JSONSuccess) {
return JSONFailure;
}
cell_ix = json_object_get_cell_ix(object, name, strlen(name), hash, &found);
}
object->names[object->count] = name;
object->cells[cell_ix] = object->count;
object->values[object->count] = value;
object->cell_ixs[object->count] = cell_ix;
object->hashes[object->count] = hash;
object->count++;
value->parent = json_object_get_wrapping_value(object);
return JSONSuccess;
}