From 90f983ced2aacce061ca96950caf3f8c09e6a17d Mon Sep 17 00:00:00 2001 From: "miloyip@gmail.com" Date: Thu, 15 Nov 2012 03:46:14 +0000 Subject: [PATCH] Fixed Issue 46: old style cast to 'void*' casts away const in document.h git-svn-id: https://rapidjson.googlecode.com/svn/trunk@88 c5894555-1306-4e8d-425f-1f6f381ee07c --- build/premake4.lua | 2 +- include/rapidjson/document.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/premake4.lua b/build/premake4.lua index e472f5a..0c131b5 100644 --- a/build/premake4.lua +++ b/build/premake4.lua @@ -64,7 +64,7 @@ solution "test" defines { "_CRT_SECURE_NO_WARNINGS" } configuration "gmake" - buildoptions "-msse4.2" + buildoptions "-msse4.2 -Werror=cast-qual" project "gtest" kind "StaticLib" diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index 2a602ee..6e82b68 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -152,7 +152,7 @@ public: break; case kCopyStringFlag: - Allocator::Free((void*)data_.s.str); + Allocator::Free(const_cast(data_.s.str)); break; } } @@ -670,8 +670,8 @@ private: flags_ = kCopyStringFlag; data_.s.str = (Ch *)allocator.Malloc((length + 1) * sizeof(Ch)); data_.s.length = length; - memcpy((void*)data_.s.str, s, length * sizeof(Ch)); - ((Ch*)data_.s.str)[length] = '\0'; + memcpy(const_cast(data_.s.str), s, length * sizeof(Ch)); + const_cast(data_.s.str)[length] = '\0'; } //! Assignment without calling destructor