MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / cJSON_CreateStringArray

Function cJSON_CreateStringArray

external/cJSON/cJSON.c:2741–2779  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2739}
2740
2741CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count)
2742{
2743 size_t i = 0;
2744 cJSON *n = NULL;
2745 cJSON *p = NULL;
2746 cJSON *a = NULL;
2747
2748 if ((count < 0) || (strings == NULL))
2749 {
2750 return NULL;
2751 }
2752
2753 a = cJSON_CreateArray();
2754
2755 for (i = 0; a && (i < (size_t)count); i++)
2756 {
2757 n = cJSON_CreateString(strings[i]);
2758 if(!n)
2759 {
2760 cJSON_Delete(a);
2761 return NULL;
2762 }
2763 if(!i)
2764 {
2765 a->child = n;
2766 }
2767 else
2768 {
2769 suffix_object(p,n);
2770 }
2771 p = n;
2772 }
2773
2774 if (a && a->child) {
2775 a->child->prev = n;
2776 }
2777
2778 return a;
2779}
2780
2781/* Duplication */
2782cJSON * cJSON_Duplicate_rec(const cJSON *item, size_t depth, 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