From: Eric Haszlakiewicz Date: Tue, 30 Nov 2021 03:08:02 +0000 (+0000) Subject: Drop the REFCOUNT_DEBUG code, it hasn't been used in ages. X-Git-Tag: json-c-0.16-20220414~26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=320548caf6c1447b4c44155ed0c1d85f8c842809;p=json-c Drop the REFCOUNT_DEBUG code, it hasn't been used in ages. --- diff --git a/ChangeLog b/ChangeLog index c6f7454..12ccba0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ Significant changes and bug fixes * Introduction of constant JSON_C_OBJECT_ADD_CONSTANT_KEY as a replacement of JSON_C_OBJECT_KEY_IS_CONSTANT, JSON_C_OBJECT_KEY_IS_CONSTANT becoming legacy. +* Drop REFCOUNT_DEBUG code. *** diff --git a/json_object.c b/json_object.c index 370e1d1..66fd725 100644 --- a/json_object.c +++ b/json_object.c @@ -53,9 +53,6 @@ #endif #endif -// Don't define this. It's not thread-safe. -/* #define REFCOUNT_DEBUG 1 */ - const char *json_hex_chars = "0123456789abcdefABCDEF"; static void json_object_generic_delete(struct json_object *jso); @@ -161,41 +158,6 @@ static json_object_to_json_string_fn _json_object_userdata_to_json_string; * */ JSON_NORETURN static void json_abort(const char *message); -/* ref count debugging */ - -#ifdef REFCOUNT_DEBUG - -static struct lh_table *json_object_table; - -static void json_object_init(void) __attribute__((constructor)); -static void json_object_init(void) -{ - MC_DEBUG("json_object_init: creating object table\n"); - json_object_table = lh_kptr_table_new(128, NULL); -} - -static void json_object_fini(void) __attribute__((destructor)); -static void json_object_fini(void) -{ - struct lh_entry *ent; - if (MC_GET_DEBUG()) - { - if (json_object_table->count) - { - MC_DEBUG("json_object_fini: %d referenced objects at exit\n", - json_object_table->count); - lh_foreach(json_object_table, ent) - { - struct json_object *obj = (struct json_object *)lh_entry_v(ent); - MC_DEBUG("\t%s:%p\n", json_type_to_name(obj->o_type), obj); - } - } - } - MC_DEBUG("json_object_fini: freeing object table\n"); - lh_table_free(json_object_table); -} -#endif /* REFCOUNT_DEBUG */ - /* helper for accessing the optimized string data component in json_object */ static inline char *get_string_component_mutable(struct json_object *jso) @@ -339,10 +301,6 @@ int json_object_put(struct json_object *jso) static void json_object_generic_delete(struct json_object *jso) { -#ifdef REFCOUNT_DEBUG - MC_DEBUG("json_object_delete_%s: %p\n", json_type_to_name(jso->o_type), jso); - lh_table_delete(json_object_table, jso); -#endif /* REFCOUNT_DEBUG */ printbuf_free(jso->_pb); free(jso); } @@ -364,10 +322,6 @@ static inline struct json_object *json_object_new(enum json_type o_type, size_t jso->_userdata = NULL; //jso->... // Type-specific fields must be set by caller -#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); -#endif /* REFCOUNT_DEBUG */ return jso; }