in lib/parson.c [607:665]
static JSON_Status json_object_remove_internal(JSON_Object *object, const char *name, parson_bool_t free_value) {
unsigned long hash = 0;
parson_bool_t found = PARSON_FALSE;
size_t cell = 0;
size_t item_ix = 0;
size_t last_item_ix = 0;
size_t i = 0;
size_t j = 0;
size_t x = 0;
size_t k = 0;
JSON_Value *val = NULL;
if (object == NULL) {
return JSONFailure;
}
hash = hash_string(name, strlen(name));
found = PARSON_FALSE;
cell = json_object_get_cell_ix(object, name, strlen(name), hash, &found);
if (!found) {
return JSONFailure;
}
item_ix = object->cells[cell];
if (free_value) {
val = object->values[item_ix];
json_value_free(val);
val = NULL;
}
parson_free(object->names[item_ix]);
last_item_ix = object->count - 1;
if (item_ix < last_item_ix) {
object->names[item_ix] = object->names[last_item_ix];
object->values[item_ix] = object->values[last_item_ix];
object->cell_ixs[item_ix] = object->cell_ixs[last_item_ix];
object->hashes[item_ix] = object->hashes[last_item_ix];
object->cells[object->cell_ixs[item_ix]] = item_ix;
}
object->count--;
i = cell;
j = i;
for (x = 0; x < (object->cell_capacity - 1); x++) {
j = (j + 1) & (object->cell_capacity - 1);
if (object->cells[j] == OBJECT_INVALID_IX) {
break;
}
k = object->hashes[object->cells[j]] & (object->cell_capacity - 1);
if ((j > i && (k <= i || k > j))
|| (j < i && (k <= i && k > j))) {
object->cell_ixs[object->cells[j]] = i;
object->cells[i] = object->cells[j];
i = j;
}
}
object->cells[i] = OBJECT_INVALID_IX;
return JSONSuccess;
}