Bug 1054334 - Constify xpconnect's gNoString r=nbp

This commit is contained in:
Dan Gohman 2014-08-18 12:20:42 -07:00
parent e9506a4b87
commit 875b3dcb01
2 changed files with 7 additions and 5 deletions

View File

@ -21,10 +21,12 @@ using namespace JS;
NS_IMPL_CLASSINFO(nsJSID, nullptr, 0, NS_JS_ID_CID)
NS_IMPL_ISUPPORTS_CI(nsJSID, nsIJSID)
char nsJSID::gNoString[] = "";
const char nsJSID::gNoString[] = "";
nsJSID::nsJSID()
: mID(GetInvalidIID()), mNumber(gNoString), mName(gNoString)
: mID(GetInvalidIID()),
mNumber(const_cast<char *>(gNoString)),
mName(const_cast<char *>(gNoString))
{
}
@ -78,7 +80,7 @@ nsJSID::GetNumber(char * *aNumber)
if (!mNumber) {
if (!(mNumber = mID.ToString()))
mNumber = gNoString;
mNumber = const_cast<char *>(gNoString);
}
*aNumber = NS_strdup(mNumber);

View File

@ -2743,7 +2743,7 @@ public:
bool InitWithName(const nsID& id, const char *nameString);
bool SetName(const char* name);
void SetNameToNoString()
{MOZ_ASSERT(!mName, "name already set"); mName = gNoString;}
{MOZ_ASSERT(!mName, "name already set"); mName = const_cast<char *>(gNoString);}
bool NameIsSet() const {return nullptr != mName;}
const nsID& ID() const {return mID;}
bool IsValid() const {return !mID.Equals(GetInvalidIID());}
@ -2758,7 +2758,7 @@ public:
protected:
virtual ~nsJSID();
static char gNoString[];
static const char gNoString[];
nsID mID;
char* mNumber;
char* mName;