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

Function cJSON_CreateDoubleArray

cJSON.c:2616–2654  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2614}
2615
2616CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count)
2617{
2618 size_t i = 0;
2619 cJSON *n = NULL;
2620 cJSON *p = NULL;
2621 cJSON *a = NULL;
2622
2623 if ((count < 0) || (numbers == NULL))
2624 {
2625 return NULL;
2626 }
2627
2628 a = cJSON_CreateArray();
2629
2630 for(i = 0; a && (i < (size_t)count); i++)
2631 {
2632 n = cJSON_CreateNumber(numbers[i]);
2633 if(!n)
2634 {
2635 cJSON_Delete(a);
2636 return NULL;
2637 }
2638 if(!i)
2639 {
2640 a->child = n;
2641 }
2642 else
2643 {
2644 suffix_object(p, n);
2645 }
2646 p = n;
2647 }
2648
2649 if (a && a->child) {
2650 a->child->prev = n;
2651 }
2652
2653 return a;
2654}
2655
2656CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count)
2657{

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