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

Function cJSON_CreateStringArray

lib/cJSON.c:2363–2397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2361}
2362
2363cJSON *cJSON_CreateStringArray(const char **strings, int count)
2364{
2365 size_t i = 0;
2366 cJSON *n = NULL;
2367 cJSON *p = NULL;
2368 cJSON *a = NULL;
2369
2370 if (count < 0)
2371 {
2372 return NULL;
2373 }
2374
2375 a = cJSON_CreateArray();
2376
2377 for (i = 0; a && (i < (size_t)count); i++)
2378 {
2379 n = cJSON_CreateString(strings[i]);
2380 if(!n)
2381 {
2382 cJSON_Delete(a);
2383 return NULL;
2384 }
2385 if(!i)
2386 {
2387 a->child = n;
2388 }
2389 else
2390 {
2391 suffix_object(p,n);
2392 }
2393 p = n;
2394 }
2395
2396 return a;
2397}
2398
2399/* Duplication */
2400cJSON *cJSON_Duplicate(const cJSON *item, cjbool recurse)

Callers

nothing calls this directly

Calls 4

cJSON_CreateArrayFunction · 0.70
cJSON_CreateStringFunction · 0.70
cJSON_DeleteFunction · 0.70
suffix_objectFunction · 0.70

Tested by

no test coverage detected