From cced9e43b2b4cbeaf05254fec1737427258a5250 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sat, 24 Jan 2015 11:32:47 +1100 Subject: [PATCH] Add a helper function to libckpool for setting a json object --- src/libckpool.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libckpool.h b/src/libckpool.h index 65fb4ae4..1b24d9c2 100644 --- a/src/libckpool.h +++ b/src/libckpool.h @@ -370,6 +370,14 @@ static inline void _json_set_bool(json_t *val, const char *key, bool boolean, } #define json_set_bool(val, key, boolean) _json_set_bool(val, key, boolean, __FILE__, __func__, __LINE__) +static inline void _json_set_object(json_t *val, const char *key, json_t *object, + const char *file, const char *func, const int line) +{ + if (unlikely(json_object_set_new_nocheck(val, key, object))) + LOGERR("Failed to set json object from %s %s:%d", file, func, line); +} +#define json_set_object(val, key, object) _json_set_object(val, key, object, __FILE__, __func__, __LINE__) + void rename_proc(const char *name); void create_pthread(pthread_t *thread, void *(*start_routine)(void *), void *arg); void join_pthread(pthread_t thread);