MCPcopy Create free account
hub / github.com/Netis/cloud-probe / cJSON_CreateStringArray

Function cJSON_CreateStringArray

cpworker/src/cJSON/cJSON.c:2688–2726  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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