Piotr Caban : msvcp110: Fix Yarn::operator=(const char*) implementation.

Alexandre Julliard julliard at wine.codeweavers.com
Sat May 14 10:07:27 CDT 2016


Module: wine
Branch: master
Commit: f8a0f90effcb0ff2d5f453079c47f4881483744a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f8a0f90effcb0ff2d5f453079c47f4881483744a

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Tue May 10 15:23:58 2016 +0200

msvcp110: Fix Yarn::operator=(const char*) implementation.

Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msvcp90/string.c | 40 ++++++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/dlls/msvcp90/string.c b/dlls/msvcp90/string.c
index 9f0d7fe..e102020 100644
--- a/dlls/msvcp90/string.c
+++ b/dlls/msvcp90/string.c
@@ -1644,17 +1644,19 @@ _Yarn_char* __thiscall _Yarn_char_op_assign_cstr(_Yarn_char *this, const char *s
 {
     TRACE("(%p %p)\n", this, str);
 
-    _Yarn_char__Tidy(this);
-
-    if(str) {
-        MSVCP_size_t len = strlen(str);
-
-        this->str = MSVCRT_operator_new((len+1)*sizeof(char));
-        if(!this->str) {
-            ERR("out of memory\n");
-            return NULL;
+    if(str != this->str) {
+        _Yarn_char__Tidy(this);
+
+        if(str) {
+            MSVCP_size_t len = strlen(str);
+
+            this->str = MSVCRT_operator_new((len+1)*sizeof(char));
+            if(!this->str) {
+                ERR("out of memory\n");
+                return NULL;
+            }
+            memcpy(this->str, str, (len+1)*sizeof(char));
         }
-        memcpy(this->str, str, (len+1)*sizeof(char));
     }
     return this;
 }
@@ -1762,17 +1764,19 @@ _Yarn_wchar* __thiscall _Yarn_wchar_op_assign_cstr(_Yarn_wchar *this, const wcha
 {
     TRACE("(%p %p)\n", this, str);
 
-    _Yarn_wchar__Tidy(this);
+    if(str != this->str) {
+        _Yarn_wchar__Tidy(this);
 
-    if(str) {
-        MSVCP_size_t len = wcslen(str);
+        if(str) {
+            MSVCP_size_t len = wcslen(str);
 
-        this->str = MSVCRT_operator_new((len+1)*sizeof(wchar_t));
-        if(!this->str) {
-            ERR("out of memory\n");
-            return NULL;
+            this->str = MSVCRT_operator_new((len+1)*sizeof(wchar_t));
+            if(!this->str) {
+                ERR("out of memory\n");
+                return NULL;
+            }
+            memcpy(this->str, str, (len+1)*sizeof(wchar_t));
         }
-        memcpy(this->str, str, (len+1)*sizeof(wchar_t));
     }
     return this;
 }




More information about the wine-cvs mailing list