mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
Support creating empty arrays with cJSON_Create*Array().
This commit is contained in:
parent
203a0dec6f
commit
5da11d6bea
8
cJSON.c
8
cJSON.c
@ -2540,7 +2540,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count)
|
|||||||
cJSON *p = NULL;
|
cJSON *p = NULL;
|
||||||
cJSON *a = NULL;
|
cJSON *a = NULL;
|
||||||
|
|
||||||
if ((count < 0) || (numbers == NULL))
|
if ((count < 0) || ((count > 0) && (numbers == NULL)))
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -2580,7 +2580,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count)
|
|||||||
cJSON *p = NULL;
|
cJSON *p = NULL;
|
||||||
cJSON *a = NULL;
|
cJSON *a = NULL;
|
||||||
|
|
||||||
if ((count < 0) || (numbers == NULL))
|
if ((count < 0) || ((count > 0) && (numbers == NULL)))
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -2620,7 +2620,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count)
|
|||||||
cJSON *p = NULL;
|
cJSON *p = NULL;
|
||||||
cJSON *a = NULL;
|
cJSON *a = NULL;
|
||||||
|
|
||||||
if ((count < 0) || (numbers == NULL))
|
if ((count < 0) || ((count > 0) && (numbers == NULL)))
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -2660,7 +2660,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int co
|
|||||||
cJSON *p = NULL;
|
cJSON *p = NULL;
|
||||||
cJSON *a = NULL;
|
cJSON *a = NULL;
|
||||||
|
|
||||||
if ((count < 0) || (strings == NULL))
|
if ((count < 0) || ((count > 0) && (strings == NULL)))
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user