mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
reformatting: cJSON_CreateStringArray
This commit is contained in:
parent
e272f7285e
commit
e6fd236f00
28
cJSON.c
28
cJSON.c
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user