MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / cJSON_CreateIntArray

Function cJSON_CreateIntArray

lib/cJSON.c:2256–2289  ·  view source on GitHub ↗

Create Arrays: */

Source from the content-addressed store, hash-verified

2254
2255/* Create Arrays: */
2256cJSON *cJSON_CreateIntArray(const int *numbers, int count)
2257{
2258 size_t i = 0;
2259 cJSON *n = NULL;
2260 cJSON *p = NULL;
2261 cJSON *a = NULL;
2262
2263 if (count < 0)
2264 {
2265 return NULL;
2266 }
2267
2268 a = cJSON_CreateArray();
2269 for(i = 0; a && (i < (size_t)count); i++)
2270 {
2271 n = cJSON_CreateNumber(numbers[i]);
2272 if (!n)
2273 {
2274 cJSON_Delete(a);
2275 return NULL;
2276 }
2277 if(!i)
2278 {
2279 a->child = n;
2280 }
2281 else
2282 {
2283 suffix_object(p, n);
2284 }
2285 p = n;
2286 }
2287
2288 return a;
2289}
2290
2291cJSON *cJSON_CreateFloatArray(const float *numbers, int count)
2292{

Callers

nothing calls this directly

Calls 4

cJSON_CreateArrayFunction · 0.70
cJSON_CreateNumberFunction · 0.70
cJSON_DeleteFunction · 0.70
suffix_objectFunction · 0.70

Tested by

no test coverage detected