提交 1f543f0e 编写于 作者: M Max Bruckner

cast_away_const: Generalize for void*

上级 eaa90a6b
......@@ -1892,9 +1892,9 @@ CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSO
#pragma GCC diagnostic ignored "-Wcast-qual"
#endif
/* helper function to cast away const */
static char* cast_away_const_from_string(const char* string)
static void* cast_away_const(const void* string)
{
return (char*)string;
return (void*)string;
}
#if defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))
#pragma GCC diagnostic pop
......@@ -1911,7 +1911,7 @@ CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJ
{
global_hooks.deallocate(item->string);
}
item->string = cast_away_const_from_string(string);
item->string = (char*)cast_away_const(string);
item->type |= cJSON_StringIsConst;
cJSON_AddItemToArray(object, item);
}
......@@ -2204,7 +2204,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string)
if (item != NULL)
{
item->type = cJSON_String | cJSON_IsReference;
item->valuestring = cast_away_const_from_string(string);
item->valuestring = (char*)cast_away_const(string);
}
return item;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册