MCPcopy Index your code
hub / github.com/binbyu/Reader / cJSON_CreateStringArray

Function cJSON_CreateStringArray

opensrc/cjson/cJSON.c:2515–2549  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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