MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / cJSON_CreateIntArray

Function cJSON_CreateIntArray

TheForceEngine/TFE_System/cJSON.c:2555–2593  ·  view source on GitHub ↗

Create Arrays: */

Source from the content-addressed store, hash-verified

2553
2554/* Create Arrays: */
2555CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count)
2556{
2557 size_t i = 0;
2558 cJSON *n = NULL;
2559 cJSON *p = NULL;
2560 cJSON *a = NULL;
2561
2562 if ((count < 0) || (numbers == NULL))
2563 {
2564 return NULL;
2565 }
2566
2567 a = cJSON_CreateArray();
2568
2569 for(i = 0; a && (i < (size_t)count); i++)
2570 {
2571 n = cJSON_CreateNumber(numbers[i]);
2572 if (!n)
2573 {
2574 cJSON_Delete(a);
2575 return NULL;
2576 }
2577 if(!i)
2578 {
2579 a->child = n;
2580 }
2581 else
2582 {
2583 suffix_object(p, n);
2584 }
2585 p = n;
2586 }
2587
2588 if (a && a->child) {
2589 a->child->prev = n;
2590 }
2591
2592 return a;
2593}
2594
2595CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count)
2596{

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