From 1adfba098ee0ac71b420590b17c1c65bb2318744 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 26 May 2021 14:28:56 +0200 Subject: treewide: eliminate dead code and unused functions Signed-off-by: Jo-Philipp Wich --- util.h | 105 +---------------------------------------------------------------- 1 file changed, 1 insertion(+), 104 deletions(-) (limited to 'util.h') diff --git a/util.h b/util.h index c4ea087..858a3fd 100644 --- a/util.h +++ b/util.h @@ -36,8 +36,6 @@ #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) #endif -#define JSON_C_TO_STRING_STRICT (1<<31) - /* vector macros */ @@ -71,16 +69,7 @@ (&((vec)->entries[(vec)->count - 1])) -/* debug helper */ - -static inline uint32_t getrefcnt(json_object *v) { - struct { - enum json_type o_type; - uint32_t _ref_count; - } *spy = (void *)v; - - return spy ? spy->_ref_count : 0; -} +/* "failsafe" utility functions */ static inline void *xalloc(size_t size) { void *ptr = calloc(1, size); @@ -93,9 +82,6 @@ static inline void *xalloc(size_t size) { return ptr; } - -/* "failsafe" utility functions */ - static inline void *xrealloc(void *ptr, size_t size) { ptr = realloc(ptr, size); @@ -118,95 +104,6 @@ static inline char *xstrdup(const char *s) { return ptr; } -static inline json_object *xjs_new_object(void) { - json_object *ptr = json_object_new_object(); - - if (!ptr) { - fprintf(stderr, "Out of memory\n"); - abort(); - } - - return ptr; -} - -static inline json_object *xjs_new_array(void) { - json_object *ptr = json_object_new_array(); - - if (!ptr) { - fprintf(stderr, "Out of memory\n"); - abort(); - } - - return ptr; -} - -static inline json_object *xjs_new_array_size(int size) { - json_object *ptr = json_object_new_array_ext(size); - - if (!ptr) { - fprintf(stderr, "Out of memory\n"); - abort(); - } - - return ptr; -} - -static inline json_object *xjs_new_int64(int64_t n) { - json_object *ptr = json_object_new_int64(n); - - if (!ptr) { - fprintf(stderr, "Out of memory\n"); - abort(); - } - - return ptr; -} - -static inline json_object *xjs_new_uint64(uint64_t n) { - json_object *ptr = json_object_new_uint64(n); - - if (!ptr) { - fprintf(stderr, "Out of memory\n"); - abort(); - } - - return ptr; -} - -static inline json_object *xjs_new_string(const char *s) { - json_object *ptr = json_object_new_string(s); - - if (!ptr) { - fprintf(stderr, "Out of memory\n"); - abort(); - } - - return ptr; -} - -static inline json_object *xjs_new_string_len(const char *s, size_t len) { - json_object *ptr = json_object_new_string_len(s, len); - - if (!ptr) { - fprintf(stderr, "Out of memory\n"); - abort(); - } - - return ptr; -} - -static inline json_object *xjs_new_boolean(bool v) { - json_object *ptr = json_object_new_boolean(v); - - if (!ptr) { - fprintf(stderr, "Out of memory\n"); - abort(); - } - - return ptr; -} - - static inline struct json_tokener *xjs_new_tokener(void) { struct json_tokener *tok = json_tokener_new(); -- cgit v1.2.3