From c132ed8d5bd9cd92cb85800db33c4b79c5d6b801 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Tue, 26 Nov 2013 13:21:43 +0400 Subject: [PATCH] qmgr: Use helper to return string value for File. --- dlls/qmgr/file.c | 16 ++++------------ dlls/qmgr/job.c | 18 ------------------ dlls/qmgr/qmgr.h | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 30 deletions(-) diff --git a/dlls/qmgr/file.c b/dlls/qmgr/file.c index ccba81b0004..0e415a9082e 100644 --- a/dlls/qmgr/file.c +++ b/dlls/qmgr/file.c @@ -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( diff --git a/dlls/qmgr/job.c b/dlls/qmgr/job.c index 5be16767b6e..ac7deaf23b4 100644 --- a/dlls/qmgr/job.c +++ b/dlls/qmgr/job.c @@ -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); diff --git a/dlls/qmgr/qmgr.h b/dlls/qmgr/qmgr.h index 1f64d4124a2..63d9f91d9f8 100644 --- a/dlls/qmgr/qmgr.h +++ b/dlls/qmgr/qmgr.h @@ -29,6 +29,7 @@ #include #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)