Add cJSON_CreateStringReference

This commit is contained in:
Max Bruckner
2017-11-28 02:02:55 +01:00
parent 440390a9a5
commit eaa90a6b74
3 changed files with 27 additions and 0 deletions

12
cJSON.c
View File

@@ -2198,6 +2198,18 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string)
return item;
}
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 = cast_away_const_from_string(string);
}
return item;
}
CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw)
{
cJSON *item = cJSON_New_Item(&global_hooks);