Commit aa8e2a16 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

shell32: Combine the two strdupAtoW functions.

parent 42811d77
......@@ -585,7 +585,7 @@ HICON WINAPI ExtractIconA(HINSTANCE hInstance, const char *file, UINT nIconIndex
fileW = strdupAtoW(file);
ret = ExtractIconW(hInstance, fileW, nIconIndex);
heap_free(fileW);
free(fileW);
return ret;
}
......
......@@ -239,7 +239,7 @@ static inline WCHAR *strdupAtoW(const char *str)
if (!str) return NULL;
len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
ret = heap_alloc(len * sizeof(WCHAR));
ret = malloc(len * sizeof(WCHAR));
if (ret)
MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
......
......@@ -202,17 +202,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 );
WCHAR *p = malloc( len * sizeof(WCHAR) );
if( !p )
return p;
MultiByteToWideChar( CP_ACP, 0, str, -1, p, len );
return p;
}
/**************************************************************************
* IPersistFile_QueryInterface
*/
......@@ -1342,7 +1331,7 @@ static HRESULT WINAPI IShellLinkA_fnSetDescription(IShellLinkA *iface, LPCSTR ps
if (pszName)
{
descrW = heap_strdupAtoW(pszName);
descrW = strdupAtoW(pszName);
if (!descrW) return E_OUTOFMEMORY;
}
else
......@@ -1378,7 +1367,7 @@ static HRESULT WINAPI IShellLinkA_fnSetWorkingDirectory(IShellLinkA *iface, LPCS
TRACE("(%p)->(dir=%s)\n",This, pszDir);
dirW = heap_strdupAtoW(pszDir);
dirW = strdupAtoW(pszDir);
if (!dirW) return E_OUTOFMEMORY;
hr = IShellLinkW_SetWorkingDirectory(&This->IShellLinkW_iface, dirW);
......@@ -1412,7 +1401,7 @@ static HRESULT WINAPI IShellLinkA_fnSetArguments(IShellLinkA *iface, LPCSTR pszA
if (pszArgs)
{
argsW = heap_strdupAtoW(pszArgs);
argsW = strdupAtoW(pszArgs);
if (!argsW) return E_OUTOFMEMORY;
}
else
......@@ -1475,7 +1464,7 @@ static HRESULT WINAPI IShellLinkA_fnSetIconLocation(IShellLinkA *iface, LPCSTR p
if (path)
{
pathW = heap_strdupAtoW(path);
pathW = strdupAtoW(path);
if (!pathW)
return E_OUTOFMEMORY;
}
......@@ -1495,7 +1484,7 @@ static HRESULT WINAPI IShellLinkA_fnSetRelativePath(IShellLinkA *iface, LPCSTR p
TRACE("(%p)->(path=%s %lx)\n",This, pszPathRel, dwReserved);
pathW = heap_strdupAtoW(pszPathRel);
pathW = strdupAtoW(pszPathRel);
if (!pathW) return E_OUTOFMEMORY;
hr = IShellLinkW_SetRelativePath(&This->IShellLinkW_iface, pathW, dwReserved);
......@@ -1523,9 +1512,8 @@ static HRESULT WINAPI IShellLinkA_fnSetPath(IShellLinkA *iface, LPCSTR pszFile)
if (!pszFile) return E_INVALIDARG;
str = heap_strdupAtoW(pszFile);
if( !str )
return E_OUTOFMEMORY;
str = strdupAtoW(pszFile);
if (!str) return E_OUTOFMEMORY;
r = IShellLinkW_SetPath(&This->IShellLinkW_iface, str);
free( str );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment