mirror of
https://github.com/json-c/json-c.git
synced 2026-04-08 06:49:07 +08:00
Change json_object_put to return 1 if the object passed was actually freed. (or 0 if only the reference count was decremented)
This commit is contained in:
@@ -139,7 +139,7 @@ extern struct json_object* json_object_get(struct json_object *jso)
|
|||||||
return jso;
|
return jso;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void json_object_put(struct json_object *jso)
|
int json_object_put(struct json_object *jso)
|
||||||
{
|
{
|
||||||
if(jso)
|
if(jso)
|
||||||
{
|
{
|
||||||
@@ -149,8 +149,10 @@ extern void json_object_put(struct json_object *jso)
|
|||||||
if (jso->_user_delete)
|
if (jso->_user_delete)
|
||||||
jso->_user_delete(jso, jso->_userdata);
|
jso->_user_delete(jso, jso->_userdata);
|
||||||
jso->_delete(jso);
|
jso->_delete(jso);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -410,7 +412,7 @@ json_bool json_object_object_get_ex(struct json_object* jso, const char *key, st
|
|||||||
|
|
||||||
void json_object_object_del(struct json_object* jso, const char *key)
|
void json_object_object_del(struct json_object* jso, const char *key)
|
||||||
{
|
{
|
||||||
lh_table_delete(jso->o.c_object, key);
|
lh_table_delete(jso->o.c_object, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -112,9 +112,9 @@ extern struct json_object* json_object_get(struct json_object *obj);
|
|||||||
* imbalance in the reference count.
|
* imbalance in the reference count.
|
||||||
*
|
*
|
||||||
* @param obj the json_object instance
|
* @param obj the json_object instance
|
||||||
|
* @returns 1 if the object was freed.
|
||||||
*/
|
*/
|
||||||
extern void json_object_put(struct json_object *obj);
|
int json_object_put(struct json_object *obj);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the json_object is of a given type
|
* Check if the json_object is of a given type
|
||||||
|
|||||||
Reference in New Issue
Block a user