MCPcopy Create free account
hub / github.com/alibaba/CicadaPlayer / cJSON_CreateFloatArray

Function cJSON_CreateFloatArray

framework/utils/cJSON.c:2441–2475  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2439}
2440
2441CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count)
2442{
2443 size_t i = 0;
2444 cJSON *n = NULL;
2445 cJSON *p = NULL;
2446 cJSON *a = NULL;
2447
2448 if ((count < 0) || (numbers == NULL))
2449 {
2450 return NULL;
2451 }
2452
2453 a = cJSON_CreateArray();
2454
2455 for(i = 0; a && (i < (size_t)count); i++)
2456 {
2457 n = cJSON_CreateNumber((double)numbers[i]);
2458 if(!n)
2459 {
2460 cJSON_Delete(a);
2461 return NULL;
2462 }
2463 if(!i)
2464 {
2465 a->child = n;
2466 }
2467 else
2468 {
2469 suffix_object(p, n);
2470 }
2471 p = n;
2472 }
2473
2474 return a;
2475}
2476
2477CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count)
2478{

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