MCPcopy Create free account
hub / github.com/binbyu/Reader / cJSON_CreateIntArray

Function cJSON_CreateIntArray

opensrc/cjson/cJSON.c:2408–2441  ·  view source on GitHub ↗

Create Arrays: */

Source from the content-addressed store, hash-verified

2406
2407/* Create Arrays: */
2408CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count)
2409{
2410 size_t i = 0;
2411 cJSON *n = NULL;
2412 cJSON *p = NULL;
2413 cJSON *a = NULL;
2414
2415 if ((count < 0) || (numbers == NULL))
2416 {
2417 return NULL;
2418 }
2419
2420 a = cJSON_CreateArray();
2421 for(i = 0; a && (i < (size_t)count); i++)
2422 {
2423 n = cJSON_CreateNumber(numbers[i]);
2424 if (!n)
2425 {
2426 cJSON_Delete(a);
2427 return NULL;
2428 }
2429 if(!i)
2430 {
2431 a->child = n;
2432 }
2433 else
2434 {
2435 suffix_object(p, n);
2436 }
2437 p = n;
2438 }
2439
2440 return a;
2441}
2442
2443CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count)
2444{

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