MCPcopy Create free account
hub / github.com/SVF-tools/SVF / cJSON_CreateStringArray

Function cJSON_CreateStringArray

svf/lib/Util/cJSON.cpp:2678–2717  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2676}
2677
2678CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count)
2679{
2680 size_t i = 0;
2681 cJSON *n = NULL;
2682 cJSON *p = NULL;
2683 cJSON *a = NULL;
2684
2685 if ((count < 0) || (strings == NULL))
2686 {
2687 return NULL;
2688 }
2689
2690 a = cJSON_CreateArray();
2691
2692 for (i = 0; a && (i < (size_t)count); i++)
2693 {
2694 n = cJSON_CreateString(strings[i]);
2695 if(!n)
2696 {
2697 cJSON_Delete(a);
2698 return NULL;
2699 }
2700 if(!i)
2701 {
2702 a->child = n;
2703 }
2704 else
2705 {
2706 suffix_object(p,n);
2707 }
2708 p = n;
2709 }
2710
2711 if (a && a->child)
2712 {
2713 a->child->prev = n;
2714 }
2715
2716 return a;
2717}
2718
2719/* Duplication */
2720CJSON_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