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

Function cJSON_CreateFloatArray

cJSON.c:2576–2614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2574}
2575
2576CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count)
2577{
2578 size_t i = 0;
2579 cJSON *n = NULL;
2580 cJSON *p = NULL;
2581 cJSON *a = NULL;
2582
2583 if ((count < 0) || (numbers == NULL))
2584 {
2585 return NULL;
2586 }
2587
2588 a = cJSON_CreateArray();
2589
2590 for(i = 0; a && (i < (size_t)count); i++)
2591 {
2592 n = cJSON_CreateNumber((double)numbers[i]);
2593 if(!n)
2594 {
2595 cJSON_Delete(a);
2596 return NULL;
2597 }
2598 if(!i)
2599 {
2600 a->child = n;
2601 }
2602 else
2603 {
2604 suffix_object(p, n);
2605 }
2606 p = n;
2607 }
2608
2609 if (a && a->child) {
2610 a->child->prev = n;
2611 }
2612
2613 return a;
2614}
2615
2616CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count)
2617{

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