From dba2472e839b2382037b7d72b85b67519d6b3701 Mon Sep 17 00:00:00 2001 From: Neil Rashbrook Date: Mon, 20 Jul 2009 21:04:44 +0100 Subject: [PATCH] Bug 504660 Make sEmptyBuffer non-const so EnsureMutable can safely use it for an empty string r=bsmedberg --- xpcom/string/public/nsCharTraits.h | 4 ++-- xpcom/string/public/nsTString.h | 4 ++-- xpcom/string/src/nsSubstring.cpp | 6 +++--- xpcom/string/src/nsTSubstring.cpp | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/xpcom/string/public/nsCharTraits.h b/xpcom/string/public/nsCharTraits.h index 3a1397958230..8ac282207299 100644 --- a/xpcom/string/public/nsCharTraits.h +++ b/xpcom/string/public/nsCharTraits.h @@ -151,7 +151,7 @@ struct nsCharTraits typedef PRUint16 unsigned_char_type; typedef char incompatible_char_type; - NS_COM static const char_type *sEmptyBuffer; + NS_COM static char_type *sEmptyBuffer; static void @@ -441,7 +441,7 @@ struct nsCharTraits typedef unsigned char unsigned_char_type; typedef PRUnichar incompatible_char_type; - NS_COM static const char_type *sEmptyBuffer; + NS_COM static char_type *sEmptyBuffer; static void diff --git a/xpcom/string/public/nsTString.h b/xpcom/string/public/nsTString.h index a407cb042447..915b84bc6f1b 100644 --- a/xpcom/string/public/nsTString.h +++ b/xpcom/string/public/nsTString.h @@ -560,11 +560,11 @@ class nsTXPIDLString_CharT : public nsTString_CharT public: nsTXPIDLString_CharT() - : string_type(const_cast(char_traits::sEmptyBuffer), 0, F_TERMINATED | F_VOIDED) {} + : string_type(char_traits::sEmptyBuffer, 0, F_TERMINATED | F_VOIDED) {} // copy-constructor required to avoid default nsTXPIDLString_CharT( const self_type& str ) - : string_type(const_cast(char_traits::sEmptyBuffer), 0, F_TERMINATED | F_VOIDED) + : string_type(char_traits::sEmptyBuffer, 0, F_TERMINATED | F_VOIDED) { Assign(str); } diff --git a/xpcom/string/src/nsSubstring.cpp b/xpcom/string/src/nsSubstring.cpp index e697c3754c3b..a1975909fe66 100644 --- a/xpcom/string/src/nsSubstring.cpp +++ b/xpcom/string/src/nsSubstring.cpp @@ -54,10 +54,10 @@ // --------------------------------------------------------------------------- -static const PRUnichar gNullChar = 0; +static PRUnichar gNullChar = 0; -const char* nsCharTraits ::sEmptyBuffer = (const char*) &gNullChar; -const PRUnichar* nsCharTraits::sEmptyBuffer = &gNullChar; +char* nsCharTraits ::sEmptyBuffer = (char*) &gNullChar; +PRUnichar* nsCharTraits::sEmptyBuffer = &gNullChar; // --------------------------------------------------------------------------- diff --git a/xpcom/string/src/nsTSubstring.cpp b/xpcom/string/src/nsTSubstring.cpp index ccc715e1873d..f2fea754fc4e 100644 --- a/xpcom/string/src/nsTSubstring.cpp +++ b/xpcom/string/src/nsTSubstring.cpp @@ -59,7 +59,7 @@ nsTSubstring_CharT::nsTSubstring_CharT(const substring_tuple_type& tuple) } nsTSubstring_CharT::nsTSubstring_CharT() -: mData(const_cast(char_traits::sEmptyBuffer)), +: mData(char_traits::sEmptyBuffer), mLength(0), mFlags(F_TERMINATED) {} @@ -563,7 +563,7 @@ nsTSubstring_CharT::SetCapacity( size_type capacity ) if (capacity == 0) { ::ReleaseData(mData, mFlags); - mData = const_cast(char_traits::sEmptyBuffer); + mData = char_traits::sEmptyBuffer; mLength = 0; SetDataFlags(F_TERMINATED); }