mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
reformatting: cJSON_CreateDoubleArray
This commit is contained in:
parent
890b999e59
commit
e272f7285e
29
cJSON.c
29
cJSON.c
@ -1995,7 +1995,34 @@ cJSON *cJSON_CreateFloatArray(const float *numbers, int count)
|
||||
return a;
|
||||
}
|
||||
|
||||
cJSON *cJSON_CreateDoubleArray(const double *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!n){cJSON_Delete(a);return 0;}if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
||||
cJSON *cJSON_CreateDoubleArray(const double *numbers, int count)
|
||||
{
|
||||
int i;
|
||||
cJSON *n = 0;
|
||||
cJSON *p = 0;
|
||||
cJSON *a = cJSON_CreateArray();
|
||||
for(i = 0;a && (i < count); i++)
|
||||
{
|
||||
n = cJSON_CreateNumber(numbers[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,*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;}
|
||||
|
||||
/* Duplication */
|
||||
|
Loading…
Reference in New Issue
Block a user