reformatting: cJSON_CreateStringArray

This commit is contained in:
Max Bruckner 2016-09-30 10:53:18 +07:00
parent e272f7285e
commit e6fd236f00

28
cJSON.c
View File

@ -2023,7 +2023,33 @@ cJSON *cJSON_CreateDoubleArray(const double *numbers, int count)
return a;
}
cJSON *cJSON_CreateStringArray(const char **strings,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateString(strings[i]);if(!n){cJSON_Delete(a);return 0;}if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
cJSON *cJSON_CreateStringArray(const char **strings, int count)
{
int i;
cJSON *n = 0;
cJSON *p = 0;
cJSON *a = cJSON_CreateArray();
for (i = 0; a && (i < count); i++)
{
n = cJSON_CreateString(strings[i]);
if(!n)
{
cJSON_Delete(a);
return 0;
}
if(!i)
{
a->child = n;
}
else
{
suffix_object(p,n);
}
p = n;
}
return a;
}
/* Duplication */
cJSON *cJSON_Duplicate(cJSON *item,int recurse)