MCPcopy Index your code
hub / github.com/DaveGamble/cJSON / cJSON_CreateIntArray

Function cJSON_CreateIntArray

cJSON.c:2606–2644  ·  view source on GitHub ↗

Create Arrays: */

Source from the content-addressed store, hash-verified

2604
2605/* Create Arrays: */
2606CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count)
2607{
2608 size_t i = 0;
2609 cJSON *n = NULL;
2610 cJSON *p = NULL;
2611 cJSON *a = NULL;
2612
2613 if ((count < 0) || (numbers == NULL))
2614 {
2615 return NULL;
2616 }
2617
2618 a = cJSON_CreateArray();
2619
2620 for(i = 0; a && (i < (size_t)count); i++)
2621 {
2622 n = cJSON_CreateNumber(numbers[i]);
2623 if (!n)
2624 {
2625 cJSON_Delete(a);
2626 return NULL;
2627 }
2628 if(!i)
2629 {
2630 a->child = n;
2631 }
2632 else
2633 {
2634 suffix_object(p, n);
2635 }
2636 p = n;
2637 }
2638
2639 if (a && a->child) {
2640 a->child->prev = n;
2641 }
2642
2643 return a;
2644}
2645
2646CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count)
2647{

Calls 4

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

Tested by 3

create_objectsFunction · 0.68
misc_testsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…