Commit 42d13468 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

shell32: Use the wcsdup function instead of reimplementing it.

parent 82faa823
......@@ -705,8 +705,7 @@ static HRESULT Stream_LoadAdvertiseInfo( IStream* stm, LPWSTR *str )
return E_FAIL;
}
*str = malloc( (lstrlenW(buffer.szwDarwinID) + 1) * sizeof(WCHAR) );
lstrcpyW( *str, buffer.szwDarwinID );
*str = wcsdup( buffer.szwDarwinID );
return S_OK;
}
......@@ -1161,11 +1160,9 @@ static HRESULT ShellLink_UpdatePath(LPCWSTR sPathRel, LPCWSTR path, LPCWSTR sWor
if (!*abs_path)
lstrcpyW(abs_path, sPathRel);
*psPath = malloc((lstrlenW(abs_path) + 1) * sizeof(WCHAR));
*psPath = wcsdup(abs_path);
if (!*psPath)
return E_OUTOFMEMORY;
lstrcpyW(*psPath, abs_path);
}
return S_OK;
......@@ -1745,11 +1742,9 @@ static HRESULT WINAPI IShellLinkW_fnSetIDList(IShellLinkW * iface, LPCITEMIDLIST
if ( SHGetPathFromIDListW( pidl, path ) )
{
This->sPath = malloc((lstrlenW(path) + 1) * sizeof(WCHAR));
This->sPath = wcsdup(path);
if (!This->sPath)
return E_OUTOFMEMORY;
lstrcpyW(This->sPath, path);
}
This->bDirty = TRUE;
......@@ -1779,11 +1774,9 @@ static HRESULT WINAPI IShellLinkW_fnSetDescription(IShellLinkW * iface, LPCWSTR
free(This->sDescription);
if (pszName)
{
This->sDescription = malloc( (lstrlenW( pszName ) + 1) * sizeof(WCHAR) );
This->sDescription = wcsdup(pszName);
if ( !This->sDescription )
return E_OUTOFMEMORY;
lstrcpyW( This->sDescription, pszName );
}
else
This->sDescription = NULL;
......@@ -1813,10 +1806,9 @@ static HRESULT WINAPI IShellLinkW_fnSetWorkingDirectory(IShellLinkW * iface, LPC
TRACE("(%p)->(dir=%s)\n",This, debugstr_w(pszDir));
free(This->sWorkDir);
This->sWorkDir = malloc( (lstrlenW( pszDir ) + 1) * sizeof(WCHAR) );
This->sWorkDir = wcsdup(pszDir);
if ( !This->sWorkDir )
return E_OUTOFMEMORY;
lstrcpyW( This->sWorkDir, pszDir );
This->bDirty = TRUE;
return S_OK;
......@@ -1845,10 +1837,9 @@ static HRESULT WINAPI IShellLinkW_fnSetArguments(IShellLinkW * iface, LPCWSTR ps
free(This->sArgs);
if (pszArgs)
{
This->sArgs = malloc( (lstrlenW( pszArgs ) + 1) * sizeof(WCHAR) );
This->sArgs = wcsdup(pszArgs);
if ( !This->sArgs )
return E_OUTOFMEMORY;
lstrcpyW( This->sArgs, pszArgs );
}
else This->sArgs = NULL;
......@@ -1928,11 +1919,9 @@ static HRESULT WINAPI IShellLinkW_fnSetIconLocation(IShellLinkW * iface, const W
free(This->sIcoPath);
if (path)
{
size_t len = (lstrlenW(path) + 1) * sizeof(WCHAR);
This->sIcoPath = malloc(len);
This->sIcoPath = wcsdup(path);
if (!This->sIcoPath)
return E_OUTOFMEMORY;
memcpy(This->sIcoPath, path, len);
}
else
This->sIcoPath = NULL;
......@@ -1949,10 +1938,9 @@ static HRESULT WINAPI IShellLinkW_fnSetRelativePath(IShellLinkW * iface, LPCWSTR
TRACE("(%p)->(path=%s %lx)\n",This, debugstr_w(pszPathRel), dwReserved);
free(This->sPathRel);
This->sPathRel = malloc( (lstrlenW( pszPathRel ) + 1) * sizeof(WCHAR) );
This->sPathRel = wcsdup(pszPathRel);
if ( !This->sPathRel )
return E_OUTOFMEMORY;
lstrcpyW( This->sPathRel, pszPathRel );
This->bDirty = TRUE;
return ShellLink_UpdatePath(This->sPathRel, This->sPath, This->sWorkDir, &This->sPath);
......@@ -1975,23 +1963,20 @@ static HRESULT WINAPI IShellLinkW_fnResolve(IShellLinkW * iface, HWND hwnd, DWOR
bSuccess = SHGetPathFromIDListW(This->pPidl, buffer);
if (bSuccess && *buffer) {
This->sPath = malloc((lstrlenW(buffer) + 1) * sizeof(WCHAR));
This->sPath = wcsdup(buffer);
if (!This->sPath)
return E_OUTOFMEMORY;
lstrcpyW(This->sPath, buffer);
This->bDirty = TRUE;
} else
hr = S_OK; /* don't report an error occurred while just caching information */
}
if (!This->sIcoPath && This->sPath) {
This->sIcoPath = malloc((lstrlenW(This->sPath) + 1) * sizeof(WCHAR));
This->sIcoPath = wcsdup(This->sPath);
if (!This->sIcoPath)
return E_OUTOFMEMORY;
lstrcpyW(This->sIcoPath, This->sPath);
This->iIcoNdx = 0;
This->bDirty = TRUE;
......@@ -2151,14 +2136,12 @@ static HRESULT WINAPI IShellLinkW_fnSetPath(IShellLinkW * iface, LPCWSTR pszFile
This->pPidl = SHSimpleIDListFromPathW(pszFile);
ShellLink_GetVolumeInfo(buffer, &This->volume);
This->sPath = malloc( (lstrlenW( buffer ) + 1) * sizeof(WCHAR) );
This->sPath = wcsdup(buffer);
if (!This->sPath)
{
free(unquoted);
return E_OUTOFMEMORY;
}
lstrcpyW(This->sPath, buffer);
}
This->bDirty = TRUE;
free(unquoted);
......
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