MCPcopy Create free account
hub / github.com/alibaba/CicadaPlayer / cJSON_CreateStringArray

Function cJSON_CreateStringArray

framework/utils/cJSON.c:2513–2547  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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