MCPcopy Create free account
hub / github.com/ByConity/ByConity / cJSON_CreateFloatArray

Function cJSON_CreateFloatArray

contrib/cJSON/cJSON.cpp:2492–2526  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2490}
2491
2492CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count)
2493{
2494 size_t i = 0;
2495 cJSON *n = NULL;
2496 cJSON *p = NULL;
2497 cJSON *a = NULL;
2498
2499 if ((count < 0) || (numbers == NULL))
2500 {
2501 return NULL;
2502 }
2503
2504 a = cJSON_CreateArray();
2505
2506 for(i = 0; a && (i < (size_t)count); i++)
2507 {
2508 n = cJSON_CreateNumber((double)numbers[i]);
2509 if(!n)
2510 {
2511 cJSON_Delete(a);
2512 return NULL;
2513 }
2514 if(!i)
2515 {
2516 a->child = n;
2517 }
2518 else
2519 {
2520 suffix_object(p, n);
2521 }
2522 p = n;
2523 }
2524
2525 return a;
2526}
2527
2528CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count)
2529{

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