mirror of https://github.com/akheron/jansson
add json_object_update_missing_incref
This commit is contained in:
parent
006638a6a2
commit
a3daab7e63
|
@ -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);
|
||||
|
|
16
src/value.c
16
src/value.c
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue