qmgr: Simplify string duplication using a helper.
This commit is contained in:
parent
74e37bc301
commit
8ae201548f
@ -166,7 +166,6 @@ HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner,
|
|||||||
BackgroundCopyFileImpl **file)
|
BackgroundCopyFileImpl **file)
|
||||||
{
|
{
|
||||||
BackgroundCopyFileImpl *This;
|
BackgroundCopyFileImpl *This;
|
||||||
int n;
|
|
||||||
|
|
||||||
TRACE("(%s, %s, %p)\n", debugstr_w(remoteName), debugstr_w(localName), file);
|
TRACE("(%s, %s, %p)\n", debugstr_w(remoteName), debugstr_w(localName), file);
|
||||||
|
|
||||||
@ -174,24 +173,20 @@ HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner,
|
|||||||
if (!This)
|
if (!This)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
n = (lstrlenW(remoteName) + 1) * sizeof(WCHAR);
|
This->info.RemoteName = strdupW(remoteName);
|
||||||
This->info.RemoteName = HeapAlloc(GetProcessHeap(), 0, n);
|
|
||||||
if (!This->info.RemoteName)
|
if (!This->info.RemoteName)
|
||||||
{
|
{
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
memcpy(This->info.RemoteName, remoteName, n);
|
|
||||||
|
|
||||||
n = (lstrlenW(localName) + 1) * sizeof(WCHAR);
|
This->info.LocalName = strdupW(localName);
|
||||||
This->info.LocalName = HeapAlloc(GetProcessHeap(), 0, n);
|
|
||||||
if (!This->info.LocalName)
|
if (!This->info.LocalName)
|
||||||
{
|
{
|
||||||
HeapFree(GetProcessHeap(), 0, This->info.RemoteName);
|
HeapFree(GetProcessHeap(), 0, This->info.RemoteName);
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
memcpy(This->info.LocalName, localName, n);
|
|
||||||
|
|
||||||
This->IBackgroundCopyFile2_iface.lpVtbl = &BackgroundCopyFile2Vtbl;
|
This->IBackgroundCopyFile2_iface.lpVtbl = &BackgroundCopyFile2Vtbl;
|
||||||
This->ref = 1;
|
This->ref = 1;
|
||||||
|
@ -1194,7 +1194,6 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID
|
|||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
BackgroundCopyJobImpl *This;
|
BackgroundCopyJobImpl *This;
|
||||||
int n;
|
|
||||||
|
|
||||||
TRACE("(%s,%d,%p)\n", debugstr_w(displayName), type, job);
|
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->ref = 1;
|
||||||
This->type = type;
|
This->type = type;
|
||||||
|
|
||||||
n = (strlenW(displayName) + 1) * sizeof *displayName;
|
This->displayName = strdupW(displayName);
|
||||||
This->displayName = HeapAlloc(GetProcessHeap(), 0, n);
|
|
||||||
if (!This->displayName)
|
if (!This->displayName)
|
||||||
{
|
{
|
||||||
This->cs.DebugInfo->Spare[0] = 0;
|
This->cs.DebugInfo->Spare[0] = 0;
|
||||||
@ -1219,7 +1217,6 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type, GUID
|
|||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
memcpy(This->displayName, displayName, n);
|
|
||||||
|
|
||||||
hr = CoCreateGuid(&This->jobId);
|
hr = CoCreateGuid(&This->jobId);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user