]> git.sesse.net Git - vlc/commitdiff
skins2: operator '=' return a reference.
authorRémi Duraffort <ivoire@videolan.org>
Wed, 11 Mar 2009 19:11:40 +0000 (20:11 +0100)
committerRémi Duraffort <ivoire@videolan.org>
Thu, 12 Mar 2009 12:16:59 +0000 (13:16 +0100)
modules/gui/skins2/utils/ustring.cpp
modules/gui/skins2/utils/ustring.hpp

index 483269feee85cfda64a6f77f303aa2b2bd8cafdf..76fb03cfd7acf52cfea348212f0f9942da9a9922 100644 (file)
@@ -199,8 +199,11 @@ bool UString::operator >=( const UString &rOther ) const
 }
 
 
-void UString::operator =( const UString &rOther )
+UString& UString::operator =( const UString &rOther )
 {
+    if( this == &rOther )
+        return *this;
+
     m_length = rOther.m_length;
     delete[] m_pString;
     m_pString = new uint32_t[size() + 1];
@@ -208,15 +211,20 @@ void UString::operator =( const UString &rOther )
     {
         m_pString[i] = rOther.m_pString[i];
     }
+
+    return *this;
 }
 
 
-void UString::operator +=( const UString &rOther )
+UString& UString::operator +=( const UString &rOther )
 {
+    if( this == &rOther )
+        return *this;
+
     int tempLength = this->length() + rOther.length();
     uint32_t *pTempString = new uint32_t[tempLength + 1];
     // Copy the first string
-    memcpy( pTempString, this->m_pString, 4 * this->size() );
+    memcpy( pTempString, this->m_pString, sizeof(uint32_t) * this->size() );
     // Append the second string
 //     memcpy( pTempString + 4 * size(), rOther.m_pString,
 //             4 * rOther.size() );
@@ -230,6 +238,8 @@ void UString::operator +=( const UString &rOther )
     delete[] m_pString;
     m_pString = pTempString;
     m_length = tempLength;
+
+    return *this;
 }
 
 
index 598dc7021cdf5d2e64bd910d6d65c02a66498ae0..36ad95253d5783fa3fa5c623811d10d2d23baea5 100644 (file)
@@ -58,9 +58,9 @@ class UString: public SkinObject
         bool operator >( const UString &rOther ) const;
         bool operator >=( const UString &rOther ) const;
         /// Assignment
-        void operator =( const UString &rOther );
+        UString& operator =( const UString &rOther );
         /// Concatenation with assignment
-        void operator +=( const UString &rOther );
+        UString& operator +=( const UString &rOther );
         /// Concatenation
         const UString operator +( const UString &rOther ) const;
         const UString operator +( const char *pString ) const;