Fixed json_object_object_add().

* Return value of json_object_object_add() changed from void to int.
  Return value now indicates success or failure.

* Check whether allocations are successful.

* Do not exit program from within the library.
This commit is contained in:
Alexander Klauer
2013-01-08 14:24:21 +01:00
parent 85da28c534
commit 2be921d883
4 changed files with 82 additions and 18 deletions

View File

@@ -230,8 +230,11 @@ extern struct lh_table* json_object_get_object(struct json_object *obj);
* @param obj the json_object instance
* @param key the object field name (a private copy will be duplicated)
* @param val a json_object or NULL member to associate with the given field
*
* @return On success, <code>0</code> is returned.
* On error, a negative value is returned.
*/
extern void json_object_object_add(struct json_object* obj, const char *key,
extern int json_object_object_add(struct json_object* obj, const char *key,
struct json_object *val);
/** Get the json_object associate with a given object field