MCPcopy Create free account
hub / github.com/Tencent/Hardcoder / cJSON_CreateIntArray

Function cJSON_CreateIntArray

libapp2sys/src/main/cpp/cjson/cJSON.c:2414–2447  ·  view source on GitHub ↗

Create Arrays: */

Source from the content-addressed store, hash-verified

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

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