diff --git a/mozilla/string/obsolete/nsXPIDLString.cpp b/mozilla/string/obsolete/nsXPIDLString.cpp index 0a69f8c6eab..6b2a5bbe841 100644 --- a/mozilla/string/obsolete/nsXPIDLString.cpp +++ b/mozilla/string/obsolete/nsXPIDLString.cpp @@ -119,6 +119,18 @@ nsXPIDLCString::~nsXPIDLCString() } +nsXPIDLCString& nsXPIDLCString::operator =(const char* aCString) +{ + if (mBufOwner && mBuf) + XPIDL_FREE(mBuf); + + mBuf = Copy(aCString); + mBufOwner = PR_TRUE; + + return *this; +} + + nsXPIDLCString::operator const char*() { return mBuf; diff --git a/mozilla/string/obsolete/nsXPIDLString.h b/mozilla/string/obsolete/nsXPIDLString.h index 5c36d9c9f3d..696bc24519c 100644 --- a/mozilla/string/obsolete/nsXPIDLString.h +++ b/mozilla/string/obsolete/nsXPIDLString.h @@ -214,6 +214,11 @@ public: virtual ~nsXPIDLCString(); + /** + * Assign a single-byte string to this wrapper. Copies and owns the result. + */ + nsXPIDLCString& operator =(const char* aString); + /** * Return a reference to the immutable single-byte string. */ diff --git a/mozilla/xpcom/ds/nsXPIDLString.cpp b/mozilla/xpcom/ds/nsXPIDLString.cpp index 0a69f8c6eab..6b2a5bbe841 100644 --- a/mozilla/xpcom/ds/nsXPIDLString.cpp +++ b/mozilla/xpcom/ds/nsXPIDLString.cpp @@ -119,6 +119,18 @@ nsXPIDLCString::~nsXPIDLCString() } +nsXPIDLCString& nsXPIDLCString::operator =(const char* aCString) +{ + if (mBufOwner && mBuf) + XPIDL_FREE(mBuf); + + mBuf = Copy(aCString); + mBufOwner = PR_TRUE; + + return *this; +} + + nsXPIDLCString::operator const char*() { return mBuf; diff --git a/mozilla/xpcom/ds/nsXPIDLString.h b/mozilla/xpcom/ds/nsXPIDLString.h index 5c36d9c9f3d..696bc24519c 100644 --- a/mozilla/xpcom/ds/nsXPIDLString.h +++ b/mozilla/xpcom/ds/nsXPIDLString.h @@ -214,6 +214,11 @@ public: virtual ~nsXPIDLCString(); + /** + * Assign a single-byte string to this wrapper. Copies and owns the result. + */ + nsXPIDLCString& operator =(const char* aString); + /** * Return a reference to the immutable single-byte string. */ diff --git a/mozilla/xpcom/string/obsolete/nsXPIDLString.cpp b/mozilla/xpcom/string/obsolete/nsXPIDLString.cpp index 0a69f8c6eab..6b2a5bbe841 100644 --- a/mozilla/xpcom/string/obsolete/nsXPIDLString.cpp +++ b/mozilla/xpcom/string/obsolete/nsXPIDLString.cpp @@ -119,6 +119,18 @@ nsXPIDLCString::~nsXPIDLCString() } +nsXPIDLCString& nsXPIDLCString::operator =(const char* aCString) +{ + if (mBufOwner && mBuf) + XPIDL_FREE(mBuf); + + mBuf = Copy(aCString); + mBufOwner = PR_TRUE; + + return *this; +} + + nsXPIDLCString::operator const char*() { return mBuf; diff --git a/mozilla/xpcom/string/obsolete/nsXPIDLString.h b/mozilla/xpcom/string/obsolete/nsXPIDLString.h index 5c36d9c9f3d..696bc24519c 100644 --- a/mozilla/xpcom/string/obsolete/nsXPIDLString.h +++ b/mozilla/xpcom/string/obsolete/nsXPIDLString.h @@ -214,6 +214,11 @@ public: virtual ~nsXPIDLCString(); + /** + * Assign a single-byte string to this wrapper. Copies and owns the result. + */ + nsXPIDLCString& operator =(const char* aString); + /** * Return a reference to the immutable single-byte string. */