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