MCPcopy Create free account
hub / github.com/Wassimulator/CactusViewer / cJSON_CreateStringArray

Function cJSON_CreateStringArray

src/cJSON.c:2665–2703  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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