MCPcopy Index your code
hub / github.com/antirez/botlib / cJSON_CreateStringArray

Function cJSON_CreateStringArray

cJSON.c:2656–2694  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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