add json_object_update_missing_incref

This commit is contained in:
dancal 2016-03-22 12:41:32 +09:00
parent 006638a6a2
commit a3daab7e63
2 changed files with 17 additions and 0 deletions

View File

@ -139,6 +139,7 @@ int json_object_clear(json_t *object);
int json_object_update(json_t *object, json_t *other);
int json_object_update_existing(json_t *object, json_t *other);
int json_object_update_missing(json_t *object, json_t *other);
int json_object_update_missing_incref(json_t *object, json_t *other);
void *json_object_iter(json_t *object);
void *json_object_iter_at(json_t *object, const char *key);
void *json_object_key_to_iter(const char *key);

View File

@ -209,6 +209,22 @@ int json_object_update_missing(json_t *object, json_t *other)
return 0;
}
int json_object_update_missing_incref(json_t *object, json_t *other)
{
const char *key;
json_t *value;
if(!json_is_object(object) || !json_is_object(other))
return -1;
json_object_foreach(other, key, value) {
if(!json_object_get(object, key))
json_object_set_nocheck(object, key, json_incref(value));
}
return 0;
}
void *json_object_iter(json_t *json)
{
json_object_t *object;