From 1f543f0e2842f5f5af2631756d20d0cb9a410b5a Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Tue, 28 Nov 2017 02:05:02 +0100 Subject: [PATCH] cast_away_const: Generalize for void* --- cJSON.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cJSON.c b/cJSON.c index befa6a7..3d3d5d2 100644 --- a/cJSON.c +++ b/cJSON.c @@ -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;