MCPcopy Index your code
hub / github.com/antirez/botlib / cJSON_CreateIntArray

Function cJSON_CreateIntArray

cJSON.c:2536–2574  ·  view source on GitHub ↗

Create Arrays: */

Source from the content-addressed store, hash-verified

2534
2535/* Create Arrays: */
2536CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count)
2537{
2538 size_t i = 0;
2539 cJSON *n = NULL;
2540 cJSON *p = NULL;
2541 cJSON *a = NULL;
2542
2543 if ((count < 0) || (numbers == NULL))
2544 {
2545 return NULL;
2546 }
2547
2548 a = cJSON_CreateArray();
2549
2550 for(i = 0; a && (i < (size_t)count); i++)
2551 {
2552 n = cJSON_CreateNumber(numbers[i]);
2553 if (!n)
2554 {
2555 cJSON_Delete(a);
2556 return NULL;
2557 }
2558 if(!i)
2559 {
2560 a->child = n;
2561 }
2562 else
2563 {
2564 suffix_object(p, n);
2565 }
2566 p = n;
2567 }
2568
2569 if (a && a->child) {
2570 a->child->prev = n;
2571 }
2572
2573 return a;
2574}
2575
2576CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count)
2577{

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