MCPcopy Create free account
hub / github.com/Tencent/Hardcoder / cJSON_CreateStringArray

Function cJSON_CreateStringArray

libapp2sys/src/main/cpp/cjson/cJSON.c:2521–2555  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2519}
2520
2521CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count)
2522{
2523 size_t i = 0;
2524 cJSON *n = NULL;
2525 cJSON *p = NULL;
2526 cJSON *a = NULL;
2527
2528 if ((count < 0) || (strings == NULL))
2529 {
2530 return NULL;
2531 }
2532
2533 a = cJSON_CreateArray();
2534
2535 for (i = 0; a && (i < (size_t)count); i++)
2536 {
2537 n = cJSON_CreateString(strings[i]);
2538 if(!n)
2539 {
2540 cJSON_Delete(a);
2541 return NULL;
2542 }
2543 if(!i)
2544 {
2545 a->child = n;
2546 }
2547 else
2548 {
2549 suffix_object(p,n);
2550 }
2551 p = n;
2552 }
2553
2554 return a;
2555}
2556
2557/* Duplication */
2558CJSON_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