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

Function cJSON_CreateIntArray

contrib/cJSON/cJSON.cpp:2457–2490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2455
2456/* Create Arrays: */
2457CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count)
2458{
2459 size_t i = 0;
2460 cJSON *n = NULL;
2461 cJSON *p = NULL;
2462 cJSON *a = NULL;
2463
2464 if ((count < 0) || (numbers == NULL))
2465 {
2466 return NULL;
2467 }
2468
2469 a = cJSON_CreateArray();
2470 for(i = 0; a && (i < (size_t)count); i++)
2471 {
2472 n = cJSON_CreateNumber(numbers[i]);
2473 if (!n)
2474 {
2475 cJSON_Delete(a);
2476 return NULL;
2477 }
2478 if(!i)
2479 {
2480 a->child = n;
2481 }
2482 else
2483 {
2484 suffix_object(p, n);
2485 }
2486 p = n;
2487 }
2488
2489 return a;
2490}
2491
2492CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count)
2493{

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