MCPcopy Create free account
hub / github.com/cotestatnt/esp-fs-webserver / cJSON_CreateStringArray

Function cJSON_CreateStringArray

src/json/cJSON.c:2726–2764  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2724}
2725
2726CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count)
2727{
2728 size_t i = 0;
2729 cJSON *n = NULL;
2730 cJSON *p = NULL;
2731 cJSON *a = NULL;
2732
2733 if ((count < 0) || (strings == NULL))
2734 {
2735 return NULL;
2736 }
2737
2738 a = cJSON_CreateArray();
2739
2740 for (i = 0; a && (i < (size_t)count); i++)
2741 {
2742 n = cJSON_CreateString(strings[i]);
2743 if(!n)
2744 {
2745 cJSON_Delete(a);
2746 return NULL;
2747 }
2748 if(!i)
2749 {
2750 a->child = n;
2751 }
2752 else
2753 {
2754 suffix_object(p,n);
2755 }
2756 p = n;
2757 }
2758
2759 if (a && a->child) {
2760 a->child->prev = n;
2761 }
2762
2763 return a;
2764}
2765
2766/* Duplication */
2767cJSON * 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