qmgr: Use helper to return string value for File.

This commit is contained in:
Nikolay Sivov 2013-11-26 13:21:43 +04:00 committed by Alexandre Julliard
parent 05396f18e4
commit c132ed8d5b
3 changed files with 18 additions and 30 deletions

View File

@ -94,14 +94,10 @@ static HRESULT WINAPI BITS_IBackgroundCopyFile_GetRemoteName(
LPWSTR *pVal)
{
BackgroundCopyFileImpl *This = impl_from_IBackgroundCopyFile(iface);
int n = (lstrlenW(This->info.RemoteName) + 1) * sizeof(WCHAR);
*pVal = CoTaskMemAlloc(n);
if (!*pVal)
return E_OUTOFMEMORY;
TRACE("(%p)->(%p)\n", This, pVal);
memcpy(*pVal, This->info.RemoteName, n);
return S_OK;
return return_strval(This->info.RemoteName, pVal);
}
static HRESULT WINAPI BITS_IBackgroundCopyFile_GetLocalName(
@ -109,14 +105,10 @@ static HRESULT WINAPI BITS_IBackgroundCopyFile_GetLocalName(
LPWSTR *pVal)
{
BackgroundCopyFileImpl *This = impl_from_IBackgroundCopyFile(iface);
int n = (lstrlenW(This->info.LocalName) + 1) * sizeof(WCHAR);
*pVal = CoTaskMemAlloc(n);
if (!*pVal)
return E_OUTOFMEMORY;
TRACE("(%p)->(%p)\n", This, pVal);
memcpy(*pVal, This->info.LocalName, n);
return S_OK;
return return_strval(This->info.LocalName, pVal);
}
static HRESULT WINAPI BITS_IBackgroundCopyFile_GetProgress(

View File

@ -25,7 +25,6 @@
#include "qmgr.h"
#include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
@ -34,23 +33,6 @@ static inline BOOL is_job_done(const BackgroundCopyJobImpl *job)
return job->state == BG_JOB_STATE_CANCELLED || job->state == BG_JOB_STATE_ACKNOWLEDGED;
}
static HRESULT return_strval(const WCHAR *str, WCHAR **ret)
{
int len;
if (!ret) return E_INVALIDARG;
len = strlenW(str);
*ret = CoTaskMemAlloc((len+1)*sizeof(WCHAR));
if (!*ret) return E_OUTOFMEMORY;
if (len)
strcpyW(*ret, str);
else
**ret = 0;
return S_OK;
}
static inline BackgroundCopyJobImpl *impl_from_IBackgroundCopyJob2(IBackgroundCopyJob2 *iface)
{
return CONTAINING_RECORD(iface, BackgroundCopyJobImpl, IBackgroundCopyJob2_iface);

View File

@ -29,6 +29,7 @@
#include <string.h>
#include "wine/list.h"
#include "wine/unicode.h"
/* Background copy job vtbl and related data */
typedef struct
@ -100,6 +101,19 @@ qmgr_strdup(const char *s)
return d ? memcpy(d, s, n) : NULL;
}
static inline HRESULT return_strval(const WCHAR *str, WCHAR **ret)
{
int len;
if (!ret) return E_INVALIDARG;
len = strlenW(str);
*ret = CoTaskMemAlloc((len+1)*sizeof(WCHAR));
if (!*ret) return E_OUTOFMEMORY;
strcpyW(*ret, str);
return S_OK;
}
static inline BOOL
transitionJobState(BackgroundCopyJobImpl *job, BG_JOB_STATE fromState,
BG_JOB_STATE toState)