From 40b10ee2ba9e582cb4b144ea3c3915ec496b04f2 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sat, 14 Feb 2015 11:10:03 +1100 Subject: [PATCH] Add helper to set a json integer and then delete its entry from the json --- src/ckpool.c | 10 ++++++++++ src/ckpool.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/ckpool.c b/src/ckpool.c index 95490c5e..06fddd1e 100644 --- a/src/ckpool.c +++ b/src/ckpool.c @@ -1051,6 +1051,16 @@ out: return ret; } +bool json_getdel_int(int *store, json_t *val, const char *res) +{ + bool ret; + + ret = json_get_int(store, val, res); + if (ret) + json_object_del(val, res); + return ret; +} + static void parse_btcds(ckpool_t *ckp, const json_t *arr_val, const int arr_size) { json_t *val; diff --git a/src/ckpool.h b/src/ckpool.h index 9b2eb5f9..97fb27f7 100644 --- a/src/ckpool.h +++ b/src/ckpool.h @@ -227,5 +227,6 @@ bool json_get_int64(int64_t *store, const json_t *val, const char *res); bool json_get_int(int *store, const json_t *val, const char *res); bool json_get_double(double *store, const json_t *val, const char *res); bool json_get_bool(bool *store, const json_t *val, const char *res); +bool json_getdel_int(int *store, json_t *val, const char *res); #endif /* CKPOOL_H */