Function cJSON_CreateStringReference

Synopsis

#include <cJSON.h>

cJSON * cJSON_CreateStringReference(const char *string)

Description

Create a string where valuestring references a string so it will not be freed by cJSON_Delete

Mentioned in

Source

Lines 2463-2473 in cJSON.c. Line 208 in cJSON.h.

CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string)
{
    cJSON *item = cJSON_New_Item(&global_hooks);
    if (item != NULL)
    {
        item->type = cJSON_String | cJSON_IsReference;
        item->valuestring = (char*)cast_away_const(string);
    }

    return item;
}





Add Discussion as Guest

Log in