From: Alex Henrie Subject: [PATCH v10 2/4] shell32: Move strdup functions to header file. Message-Id: <20160826043318.26732-2-alexhenrie24@gmail.com> Date: Thu, 25 Aug 2016 22:32:46 -0600 In-Reply-To: <20160826043318.26732-1-alexhenrie24@gmail.com> References: <20160826043318.26732-1-alexhenrie24@gmail.com> Cc: Sebastian Lackner Signed-off-by: Alex Henrie --- dlls/shell32/shell32_main.h | 21 +++++++++++++++++++++ dlls/shell32/shelllink.c | 21 --------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/dlls/shell32/shell32_main.h b/dlls/shell32/shell32_main.h index 0178e10..3ca4506 100644 --- a/dlls/shell32/shell32_main.h +++ b/dlls/shell32/shell32_main.h @@ -188,6 +188,27 @@ static inline WCHAR * __SHCloneStrAtoW(WCHAR ** target, const char * source) return *target; } +/* strdup on the process heap */ +static inline LPWSTR heap_strdupAtoW( LPCSTR str ) +{ + INT len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 ); + LPWSTR p = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) ); + if( !p ) + return p; + MultiByteToWideChar( CP_ACP, 0, str, -1, p, len ); + return p; +} + +static inline LPWSTR strdupW( LPCWSTR src ) +{ + LPWSTR dest; + if (!src) return NULL; + dest = HeapAlloc( GetProcessHeap(), 0, (lstrlenW(src)+1)*sizeof(WCHAR) ); + if (dest) + lstrcpyW(dest, src); + return dest; +} + extern WCHAR swShell32Name[MAX_PATH] DECLSPEC_HIDDEN; diff --git a/dlls/shell32/shelllink.c b/dlls/shell32/shelllink.c index bd3507e..fa0a33a 100644 --- a/dlls/shell32/shelllink.c +++ b/dlls/shell32/shelllink.c @@ -204,27 +204,6 @@ static inline IShellLinkImpl *impl_from_IPropertyStore(IPropertyStore *iface) static HRESULT ShellLink_UpdatePath(LPCWSTR sPathRel, LPCWSTR path, LPCWSTR sWorkDir, LPWSTR* psPath); -/* strdup on the process heap */ -static inline LPWSTR heap_strdupAtoW( LPCSTR str) -{ - INT len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 ); - LPWSTR p = HeapAlloc( GetProcessHeap(), 0, len*sizeof (WCHAR) ); - if( !p ) - return p; - MultiByteToWideChar( CP_ACP, 0, str, -1, p, len ); - return p; -} - -static inline LPWSTR strdupW( LPCWSTR src ) -{ - LPWSTR dest; - if (!src) return NULL; - dest = HeapAlloc( GetProcessHeap(), 0, (lstrlenW(src)+1)*sizeof(WCHAR) ); - if (dest) - lstrcpyW(dest, src); - return dest; -} - /************************************************************************** * IPersistFile_QueryInterface */ -- 2.9.3