Nikolay Sivov : qmgr: Simplify string duplication using a helper.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Jun 23 09:17:15 CDT 2015


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Tue Jun 23 15:14:53 2015 +0300

qmgr: Simplify string duplication using a helper.

---

 dlls/qmgr/file.c | 9 ++-------
 dlls/qmgr/job.c  | 5 +----
 2 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/dlls/qmgr/file.c b/dlls/qmgr/file.c
index 0321ab6..b92e52f 100644
--- a/dlls/qmgr/file.c
+++ b/dlls/qmgr/file.c
@@ -166,7 +166,6 @@ HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner,
                                       BackgroundCopyFileImpl **file)
 {
     BackgroundCopyFileImpl *This;
-    int n;
 
     TRACE("(%s, %s, %p)\n", debugstr_w(remoteName), debugstr_w(localName), file);
 
@@ -174,24 +173,20 @@ HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner,
     if (!This)
         return E_OUTOFMEMORY;
 
-    n = (lstrlenW(remoteName) + 1) * sizeof(WCHAR);
-    This->info.RemoteName = HeapAlloc(GetProcessHeap(), 0, n);
+    This->info.RemoteName = strdupW(remoteName);
     if (!This->info.RemoteName)
     {
         HeapFree(GetProcessHeap(), 0, This);
         return E_OUTOFMEMORY;
     }
-    memcpy(This->info.RemoteName, remoteName, n);
 
-    n = (lstrlenW(localName) + 1) * sizeof(WCHAR);
-    This->info.LocalName = HeapAlloc(GetProcessHeap(), 0, n);
+    This->info.LocalName = strdupW(localName);
     if (!This->info.LocalName)
     {
         HeapFree(GetProcessHeap(), 0, This->info.RemoteName);
         HeapFree(GetProcessHeap(), 0, This);
         return E_OUTOFMEMORY;
     }
-    memcpy(This->info.LocalName, localName, n);
 
     This->IBackgroundCopyFile2_iface.lpVtbl = &BackgroundCopyFile2Vtbl;
     This->ref = 1;
diff --git a/dlls/qmgr/job.c b/dlls/qmgr/job.c
index 8ca04ad..fda7a01 100644
--- a/dlls/qmgr/job.c
+++ b/dlls/qmgr/job.c
@@ -1194,7 +1194,6 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID
 {
     HRESULT hr;
     BackgroundCopyJobImpl *This;
-    int n;
 
     TRACE("(%s,%d,%p)\n", debugstr_w(displayName), type, job);
 
@@ -1210,8 +1209,7 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID
     This->ref = 1;
     This->type = type;
 
-    n = (strlenW(displayName) + 1) *  sizeof *displayName;
-    This->displayName = HeapAlloc(GetProcessHeap(), 0, n);
+    This->displayName = strdupW(displayName);
     if (!This->displayName)
     {
         This->cs.DebugInfo->Spare[0] = 0;
@@ -1219,7 +1217,6 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID
         HeapFree(GetProcessHeap(), 0, This);
         return E_OUTOFMEMORY;
     }
-    memcpy(This->displayName, displayName, n);
 
     hr = CoCreateGuid(&This->jobId);
     if (FAILED(hr))




More information about the wine-cvs mailing list