@@ -44,7 +44,6 @@
const char *json_number_chars = "0123456789.+-eE";
const char *json_hex_chars = "0123456789abcdefABCDEF";
static void json_object_generic_delete(struct json_object* jso);
static struct json_object* json_object_new(enum json_type o_type);
static json_object_to_json_string_fn json_object_object_to_json_string;
@@ -54,6 +53,12 @@ static json_object_to_json_string_fn json_object_int_to_json_string;
static json_object_to_json_string_fn json_object_string_to_json_string;
static json_object_to_json_string_fn json_object_array_to_json_string;
typedef void (json_object_private_delete_fn)(struct json_object *o);
static json_object_private_delete_fn json_object_string_delete;
static json_object_private_delete_fn json_object_array_delete;
static json_object_private_delete_fn json_object_object_delete;
static json_object_private_delete_fn json_object_generic_delete;
/* ref count debugging */
@@ -205,7 +210,16 @@ int json_object_put(struct json_object *jso)
if (jso->_user_delete)
jso->_user_delete(jso, jso->_userdata);
jso->_delete(jso);
if (jso->o_type == json_type_string)
json_object_string_delete(jso);
else if (jso->o_type == json_type_array)
json_object_array_delete(jso);
else if (jso->o_type == json_type_object)
json_object_object_delete(jso);
else
json_object_generic_delete(jso);
return 1;
}
@@ -232,7 +246,6 @@ static struct json_object* json_object_new(enum json_type o_type)
return NULL;
jso->o_type = o_type;
jso->_ref_count = 1;
jso->_delete = &json_object_generic_delete;
#ifdef REFCOUNT_DEBUG
lh_table_insert(json_object_table, jso, jso);
MC_DEBUG("json_object_new_%s: %p\n", json_type_to_name(jso->o_type), jso);
@@ -441,7 +454,6 @@ struct json_object* json_object_new_object(void)
struct json_object *jso = json_object_new(json_type_object);
if (!jso)
return NULL;
jso->_delete = &json_object_object_delete;
jso->_to_json_string = &json_object_object_to_json_string;
jso->o.c_object = lh_kchar_table_new(JSON_OBJECT_DEF_HASH_ENTRIES,
&json_object_lh_entry_free);
@@ -1020,7 +1032,6 @@ struct json_object* json_object_new_string(const char *s)
struct json_object *jso = json_object_new(json_type_string);
if (!jso)
return NULL;
jso->_delete = &json_object_string_delete;
jso->_to_json_string = &json_object_string_to_json_string;
jso->o.c_string.len = strlen(s);
if(jso->o.c_string.len < LEN_DIRECT_STRING_DATA) {
@@ -1043,7 +1054,6 @@ struct json_object* json_object_new_string_len(const char *s, const int len)
struct json_object *jso = json_object_new(json_type_string);
if (!jso)
return NULL;
jso->_delete = &json_object_string_delete;
jso->_to_json_string = &json_object_string_to_json_string;
if(len < LEN_DIRECT_STRING_DATA) {
dstbuf = jso->o.c_string.str.data;
@@ -1172,7 +1182,6 @@ struct json_object* json_object_new_array(void)
struct json_object *jso = json_object_new(json_type_array);
if (!jso)
return NULL;
jso->_delete = &json_object_array_delete;
jso->_to_json_string = &json_object_array_to_json_string;
jso->o.c_array = array_list_new(&json_object_array_entry_free);
if(jso->o.c_array == NULL)