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

Function cJSON_CreateStringArray

TheForceEngine/TFE_System/cJSON.c:2675–2713  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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