MCPcopy Create free account
hub / github.com/ByConity/ByConity / cJSON_CreateStringArray

Function cJSON_CreateStringArray

contrib/cJSON/cJSON.cpp:2564–2598  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2562}
2563
2564CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count)
2565{
2566 size_t i = 0;
2567 cJSON *n = NULL;
2568 cJSON *p = NULL;
2569 cJSON *a = NULL;
2570
2571 if ((count < 0) || (strings == NULL))
2572 {
2573 return NULL;
2574 }
2575
2576 a = cJSON_CreateArray();
2577
2578 for (i = 0; a && (i < (size_t)count); i++)
2579 {
2580 n = cJSON_CreateString(strings[i]);
2581 if(!n)
2582 {
2583 cJSON_Delete(a);
2584 return NULL;
2585 }
2586 if(!i)
2587 {
2588 a->child = n;
2589 }
2590 else
2591 {
2592 suffix_object(p,n);
2593 }
2594 p = n;
2595 }
2596
2597 return a;
2598}
2599
2600/* Duplication */
2601CJSON_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