Transform serial key comparison from substraction to real comparison.
Reset serial to zero in json_object_clear() to avoid it growing out of
bounds when reusing objects.
Closes GH-40.
Closes GH-41.
static int object_key_compare_serials(const void *key1, const void *key2)
{
- return (*(const object_key_t **)key1)->serial -
- (*(const object_key_t **)key2)->serial;
+ size_t a = (*(const object_key_t **)key1)->serial;
+ size_t b = (*(const object_key_t **)key2)->serial;
+
+ return a < b ? -1 : a == b ? 0 : 1;
}
static int do_dump(const json_t *json, size_t flags, int depth,
return -1;
object = json_to_object(json);
+
hashtable_clear(&object->hashtable);
+ object->serial = 0;
return 0;
}