MCPcopy Create free account
hub / github.com/BigPig0/RelayLive / cJSON_CreateStringArray

Function cJSON_CreateStringArray

ThirdParty/cjson/cJSON.c:2527–2561  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2525}
2526
2527CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count)
2528{
2529 size_t i = 0;
2530 cJSON *n = NULL;
2531 cJSON *p = NULL;
2532 cJSON *a = NULL;
2533
2534 if ((count < 0) || (strings == NULL))
2535 {
2536 return NULL;
2537 }
2538
2539 a = cJSON_CreateArray();
2540
2541 for (i = 0; a && (i < (size_t)count); i++)
2542 {
2543 n = cJSON_CreateString(strings[i]);
2544 if(!n)
2545 {
2546 cJSON_Delete(a);
2547 return NULL;
2548 }
2549 if(!i)
2550 {
2551 a->child = n;
2552 }
2553 else
2554 {
2555 suffix_object(p,n);
2556 }
2557 p = n;
2558 }
2559
2560 return a;
2561}
2562
2563/* Duplication */
2564CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse)

Callers

nothing calls this directly

Calls 4

cJSON_CreateArrayFunction · 0.85
cJSON_CreateStringFunction · 0.85
cJSON_DeleteFunction · 0.85
suffix_objectFunction · 0.85

Tested by

no test coverage detected