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

Function cJSON_CreateDoubleArray

framework/utils/cJSON.c:2477–2511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2475}
2476
2477CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count)
2478{
2479 size_t i = 0;
2480 cJSON *n = NULL;
2481 cJSON *p = NULL;
2482 cJSON *a = NULL;
2483
2484 if ((count < 0) || (numbers == NULL))
2485 {
2486 return NULL;
2487 }
2488
2489 a = cJSON_CreateArray();
2490
2491 for(i = 0;a && (i < (size_t)count); i++)
2492 {
2493 n = cJSON_CreateNumber(numbers[i]);
2494 if(!n)
2495 {
2496 cJSON_Delete(a);
2497 return NULL;
2498 }
2499 if(!i)
2500 {
2501 a->child = n;
2502 }
2503 else
2504 {
2505 suffix_object(p, n);
2506 }
2507 p = n;
2508 }
2509
2510 return a;
2511}
2512
2513CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count)
2514{

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