MCPcopy Create free account
hub / github.com/alibaba/CicadaPlayer / cJSON_CreateIntArray

Function cJSON_CreateIntArray

framework/utils/cJSON.c:2406–2439  ·  view source on GitHub ↗

Create Arrays: */

Source from the content-addressed store, hash-verified

2404
2405/* Create Arrays: */
2406CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count)
2407{
2408 size_t i = 0;
2409 cJSON *n = NULL;
2410 cJSON *p = NULL;
2411 cJSON *a = NULL;
2412
2413 if ((count < 0) || (numbers == NULL))
2414 {
2415 return NULL;
2416 }
2417
2418 a = cJSON_CreateArray();
2419 for(i = 0; a && (i < (size_t)count); i++)
2420 {
2421 n = cJSON_CreateNumber(numbers[i]);
2422 if (!n)
2423 {
2424 cJSON_Delete(a);
2425 return NULL;
2426 }
2427 if(!i)
2428 {
2429 a->child = n;
2430 }
2431 else
2432 {
2433 suffix_object(p, n);
2434 }
2435 p = n;
2436 }
2437
2438 return a;
2439}
2440
2441CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count)
2442{

Callers

nothing calls this directly

Calls 4

cJSON_CreateArrayFunction · 0.85
cJSON_CreateNumberFunction · 0.85
cJSON_DeleteFunction · 0.85
suffix_objectFunction · 0.85

Tested by

no test coverage detected