From 034003ce2bb4825b4a28dba81a415272c3813ded Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Fri, 30 Sep 2016 10:49:59 +0700 Subject: [PATCH] reformatting: cJSON_CreateString --- cJSON.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cJSON.c b/cJSON.c index 97dc795..6f0431c 100644 --- a/cJSON.c +++ b/cJSON.c @@ -1899,7 +1899,23 @@ cJSON *cJSON_CreateNumber(double num) return item; } -cJSON *cJSON_CreateString(const char *string) {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_String;item->valuestring=cJSON_strdup(string);if(!item->valuestring){cJSON_Delete(item);return 0;}}return item;} +cJSON *cJSON_CreateString(const char *string) +{ + cJSON *item = cJSON_New_Item(); + if(item) + { + item->type = cJSON_String; + item->valuestring = cJSON_strdup(string); + if(!item->valuestring) + { + cJSON_Delete(item); + return 0; + } + } + + return item; +} + cJSON *cJSON_CreateArray(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Array;return item;} cJSON *cJSON_CreateObject(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Object;return item;}