From 96ec74c9d5a395401c3596a52f9673a4b543e462 Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Fri, 30 Sep 2016 10:42:52 +0700 Subject: [PATCH] reformatting: cJSON_DetachItemFromObject --- cJSON.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cJSON.c b/cJSON.c index 8e20254..14f5e57 100644 --- a/cJSON.c +++ b/cJSON.c @@ -1746,7 +1746,23 @@ void cJSON_DeleteItemFromArray(cJSON *array, int which) cJSON_Delete(cJSON_DetachItemFromArray(array, which)); } -cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string) {int i=0;cJSON *c=object->child;while (c && cJSON_strcasecmp(c->string,string)) i++,c=c->next;if (c) return cJSON_DetachItemFromArray(object,i);return 0;} +cJSON *cJSON_DetachItemFromObject(cJSON *object, const char *string) +{ + int i = 0; + cJSON *c = object->child; + while (c && cJSON_strcasecmp(c->string,string)) + { + i++; + c = c->next; + } + if (c) + { + return cJSON_DetachItemFromArray(object, i); + } + + return 0; +} + void cJSON_DeleteItemFromObject(cJSON *object,const char *string) {cJSON_Delete(cJSON_DetachItemFromObject(object,string));} /* Replace array/object items with new ones. */