MCPcopy Create free account
hub / github.com/OpenIPC/firmware / cJSON_CreateStringArray

Function cJSON_CreateStringArray

general/package/xmdp/src/cjson/cJSON.c:2650–2684  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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