I was really confused about whether strdupW or wcsdup is preferred in shell32. Since strdupW is deprecated, let's just get rid of it so that no one else has to wonder.
-- v2: shell32: Remove unused function strdupW. shell32: Don't use strdupW or heap_* functions in shelllink.c. shell32: Don't use strdupW or heap_* functions in shelldispatch.c. shell32: Don't use strdupW or heap_* functions in shellole.c.
From: Alex Henrie alexhenrie24@gmail.com
--- dlls/shell32/shellole.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/dlls/shell32/shellole.c b/dlls/shell32/shellole.c index 589e5c5170a..055244b1e67 100644 --- a/dlls/shell32/shellole.c +++ b/dlls/shell32/shellole.c @@ -385,7 +385,7 @@ static IClassFactory * IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pc { IDefClFImpl* lpclf;
- lpclf = heap_alloc(sizeof(*lpclf)); + lpclf = malloc(sizeof(*lpclf)); lpclf->ref = 1; lpclf->IClassFactory_iface.lpVtbl = &dclfvt; lpclf->lpfnCI = lpfnCI; @@ -445,7 +445,7 @@ static ULONG WINAPI IDefClF_fnRelease(LPCLASSFACTORY iface) if (This->pcRefDll) InterlockedDecrement(This->pcRefDll);
TRACE("-- destroying IClassFactory(%p)\n",This); - heap_free(This); + free(This); }
return refCount; @@ -580,7 +580,7 @@ UINT WINAPI DragQueryFileA( LPWSTR lpszFileW = NULL;
if(lpszFile && lFile != 0xFFFFFFFF) { - lpszFileW = heap_alloc(lLength*sizeof(WCHAR)); + lpszFileW = malloc(lLength * sizeof(WCHAR)); if(lpszFileW == NULL) { goto end; } @@ -589,7 +589,7 @@ UINT WINAPI DragQueryFileA(
if(lpszFileW) { WideCharToMultiByte(CP_ACP, 0, lpszFileW, -1, lpszFile, lLength, 0, NULL); - heap_free(lpszFileW); + free(lpszFileW); } goto end; } @@ -635,7 +635,7 @@ UINT WINAPI DragQueryFileW( LPSTR lpszFileA = NULL;
if(lpszwFile && lFile != 0xFFFFFFFF) { - lpszFileA = heap_alloc(lLength); + lpszFileA = malloc(lLength); if(lpszFileA == NULL) { goto end; } @@ -644,7 +644,7 @@ UINT WINAPI DragQueryFileW(
if(lpszFileA) { MultiByteToWideChar(CP_ACP, 0, lpszFileA, -1, lpszwFile, lLength); - heap_free(lpszFileA); + free(lpszFileA); } goto end; } @@ -876,8 +876,8 @@ static ULONG WINAPI ShellImageData_Release(IShellImageData *iface) if (!ref) { GdipDisposeImage(This->image); - heap_free(This->path); - SHFree(This); + free(This->path); + free(This); }
return ref; @@ -1247,12 +1247,12 @@ static HRESULT create_shellimagedata_from_path(const WCHAR *path, IShellImageDat { ShellImageData *This;
- This = SHAlloc(sizeof(*This)); + This = malloc(sizeof(*This));
This->IShellImageData_iface.lpVtbl = &ShellImageDataVtbl; This->ref = 1;
- This->path = strdupW(path); + This->path = wcsdup(path); This->image = NULL;
*data = &This->IShellImageData_iface;
From: Alex Henrie alexhenrie24@gmail.com
--- dlls/shell32/shelldispatch.c | 52 ++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 26 deletions(-)
diff --git a/dlls/shell32/shelldispatch.c b/dlls/shell32/shelldispatch.c index fbf90bb125e..01353bda82d 100644 --- a/dlls/shell32/shelldispatch.c +++ b/dlls/shell32/shelldispatch.c @@ -244,7 +244,7 @@ static ULONG WINAPI FolderItemVerbImpl_Release(FolderItemVerb *iface) { IContextMenu_Release(This->contextmenu); SysFreeString(This->name); - heap_free(This); + free(This); }
return ref; @@ -356,7 +356,7 @@ static HRESULT FolderItemVerb_Constructor(IContextMenu *contextmenu, BSTR name,
TRACE("%p, %s\n", contextmenu, debugstr_w(name));
- This = heap_alloc(sizeof(*This)); + This = malloc(sizeof(*This)); if (!This) return E_OUTOFMEMORY;
@@ -414,7 +414,7 @@ static ULONG WINAPI FolderItemVerbsImpl_Release(FolderItemVerbs *iface) { IContextMenu_Release(This->contextmenu); DestroyMenu(This->hMenu); - heap_free(This); + free(This); }
return ref; @@ -588,7 +588,7 @@ static HRESULT FolderItemVerbs_Constructor(BSTR path, FolderItemVerbs **verbs)
*verbs = NULL;
- This = heap_alloc(sizeof(*This)); + This = malloc(sizeof(*This)); if (!This) return E_OUTOFMEMORY;
@@ -623,7 +623,7 @@ static HRESULT FolderItemVerbs_Constructor(BSTR path, FolderItemVerbs **verbs) return S_OK;
failed: - heap_free(This); + free(This); return hr; }
@@ -671,7 +671,7 @@ static ULONG WINAPI ShellLinkObject_Release(IShellLinkDual2 *iface) if (!ref) { if (This->shell_link) IShellLinkW_Release(This->shell_link); - heap_free(This); + free(This); } return ref; } @@ -899,7 +899,7 @@ static HRESULT ShellLinkObject_Constructor(FolderItemImpl *item, IShellLinkDual2
*link = NULL;
- This = heap_alloc(sizeof(*This)); + This = malloc(sizeof(*This)); if (!This) return E_OUTOFMEMORY; This->IShellLinkDual2_iface.lpVtbl = &ShellLinkObjectVtbl; This->ref = 1; @@ -909,7 +909,7 @@ static HRESULT ShellLinkObject_Constructor(FolderItemImpl *item, IShellLinkDual2 &IID_IShellLinkW, (LPVOID*)&This->shell_link); if (FAILED(hr)) { - heap_free(This); + free(This); return hr; }
@@ -918,7 +918,7 @@ static HRESULT ShellLinkObject_Constructor(FolderItemImpl *item, IShellLinkDual2 if (FAILED(hr)) { IShellLinkW_Release(This->shell_link); - heap_free(This); + free(This); return hr; }
@@ -927,7 +927,7 @@ static HRESULT ShellLinkObject_Constructor(FolderItemImpl *item, IShellLinkDual2 if (FAILED(hr)) { IShellLinkW_Release(This->shell_link); - heap_free(This); + free(This); return hr; }
@@ -979,8 +979,8 @@ static ULONG WINAPI FolderItemImpl_Release(FolderItem2 *iface) if (!ref) { Folder3_Release(&This->folder->Folder3_iface); - heap_free(This->path); - heap_free(This); + free(This->path); + free(This); } return ref; } @@ -1295,14 +1295,14 @@ static HRESULT FolderItem_Constructor(FolderImpl *folder, const WCHAR *path, Fol
*item = NULL;
- This = heap_alloc_zero(sizeof(*This)); + This = calloc(1, sizeof(*This)); if (!This) return E_OUTOFMEMORY;
This->FolderItem2_iface.lpVtbl = &FolderItemImpl_Vtbl; This->ref = 1; if (path) - This->path = strdupW(path); + This->path = wcsdup(path);
This->folder = folder; Folder3_AddRef(&folder->Folder3_iface); @@ -1362,8 +1362,8 @@ static ULONG WINAPI FolderItemsImpl_Release(FolderItems3 *iface) Folder3_Release(&This->folder->Folder3_iface); for (i = 0; i < This->item_count; i++) SysFreeString(This->item_names[i]); - heap_free(This->item_names); - heap_free(This); + free(This->item_names); + free(This); } return ref; } @@ -1623,7 +1623,7 @@ static HRESULT FolderItems_Constructor(FolderImpl *folder, FolderItems **ret)
*ret = NULL;
- This = heap_alloc_zero(sizeof(*This)); + This = calloc(1, sizeof(*This)); if (!This) return E_OUTOFMEMORY;
@@ -1650,13 +1650,13 @@ static HRESULT FolderItems_Constructor(FolderImpl *folder, FolderItems **ret) LPITEMIDLIST *pidls; ULONG fetched;
- pidls = heap_alloc(This->item_count * sizeof(*pidls)); - This->item_names = heap_alloc_zero(This->item_count * sizeof(*This->item_names)); + pidls = malloc(This->item_count * sizeof(*pidls)); + This->item_names = calloc(This->item_count, sizeof(*This->item_names));
if (!pidls || !This->item_names) { - heap_free(pidls); - heap_free(This->item_names); + free(pidls); + free(This->item_names); hr = E_OUTOFMEMORY; goto failed; } @@ -1674,7 +1674,7 @@ static HRESULT FolderItems_Constructor(FolderImpl *folder, FolderItems **ret)
ILFree(pidls[i]); } - heap_free(pidls); + free(pidls); } IEnumIDList_Release(enumidlist);
@@ -1735,7 +1735,7 @@ static ULONG WINAPI FolderImpl_Release(Folder3 *iface) SysFreeString(This->path); IShellFolder2_Release(This->folder); IDispatch_Release(This->application); - heap_free(This); + free(This); } return ref; } @@ -2005,7 +2005,7 @@ static HRESULT Folder_Constructor(IShellFolder2 *folder, LPITEMIDLIST pidl, Fold
*ret = NULL;
- This = heap_alloc(sizeof(*This)); + This = malloc(sizeof(*This)); if (!This) return E_OUTOFMEMORY;
@@ -2072,7 +2072,7 @@ static ULONG WINAPI ShellDispatch_Release(IShellDispatch6 *iface) TRACE("(%p), new refcount=%li\n", iface, ref);
if (!ref) - heap_free(This); + free(This);
return ref; } @@ -2620,7 +2620,7 @@ HRESULT WINAPI IShellDispatch_Constructor(IUnknown *outer, REFIID riid, void **p
if (outer) return CLASS_E_NOAGGREGATION;
- This = heap_alloc(sizeof(*This)); + This = malloc(sizeof(*This)); if (!This) return E_OUTOFMEMORY; This->IShellDispatch6_iface.lpVtbl = &ShellDispatchVtbl; This->ref = 1;
From: Alex Henrie alexhenrie24@gmail.com
--- dlls/shell32/shell32_main.h | 10 ---------- 1 file changed, 10 deletions(-)
diff --git a/dlls/shell32/shell32_main.h b/dlls/shell32/shell32_main.h index 33b85ee2726..f9607585184 100644 --- a/dlls/shell32/shell32_main.h +++ b/dlls/shell32/shell32_main.h @@ -231,16 +231,6 @@ HRESULT get_typeinfo(enum tid_t, ITypeInfo**) DECLSPEC_HIDDEN; void release_typelib(void) DECLSPEC_HIDDEN; void release_desktop_folder(void) DECLSPEC_HIDDEN;
-static inline WCHAR *strdupW(const WCHAR *src) -{ - WCHAR *dest; - if (!src) return NULL; - dest = heap_alloc((lstrlenW(src) + 1) * sizeof(*dest)); - if (dest) - lstrcpyW(dest, src); - return dest; -} - static inline WCHAR *strdupAtoW(const char *str) { WCHAR *ret;
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=125212
Your paranoid android.
=== debian11 (32 bit report) ===
msctf: inputprocessor.c:2437: Test failed: Expected DocumentMgr not focused Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x0040ae26).
=== debian11 (32 bit zh:CN report) ===
shell32: autocomplete.c:614: Test failed: Expected (null), got L"ab" autocomplete.c:637: Test failed: Expected (null), got L"www.ax"
=== debian11 (build log) ===
Use of uninitialized value $Flaky in addition (+) at /home/testbot/lib/WineTestBot/LogUtils.pm line 720, <$LogFile> line 25032. Use of uninitialized value $Flaky in addition (+) at /home/testbot/lib/WineTestBot/LogUtils.pm line 720, <$LogFile> line 25032. Use of uninitialized value $Flaky in addition (+) at /home/testbot/lib/WineTestBot/LogUtils.pm line 720, <$LogFile> line 25032.
From: Alex Henrie alexhenrie24@gmail.com
--- dlls/shell32/shelllink.c | 154 +++++++++++++++++++-------------------- 1 file changed, 77 insertions(+), 77 deletions(-)
diff --git a/dlls/shell32/shelllink.c b/dlls/shell32/shelllink.c index 2827b700372..0a090febd2f 100644 --- a/dlls/shell32/shelllink.c +++ b/dlls/shell32/shelllink.c @@ -208,7 +208,7 @@ static HRESULT ShellLink_UpdatePath(LPCWSTR sPathRel, LPCWSTR path, LPCWSTR sWor static inline LPWSTR heap_strdupAtoW( LPCSTR str) { INT len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 ); - LPWSTR p = heap_alloc( len*sizeof (WCHAR) ); + WCHAR *p = malloc( len * sizeof(WCHAR) ); if( !p ) return p; MultiByteToWideChar( CP_ACP, 0, str, -1, p, len ); @@ -286,8 +286,8 @@ static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFile IStream_Release( stm );
/* update file path */ - heap_free(This->filepath); - This->filepath = strdupW(pszFileName); + free(This->filepath); + This->filepath = wcsdup(pszFileName);
This->bDirty = FALSE; } @@ -309,7 +309,7 @@ BOOL run_winemenubuilder( const WCHAR *args ) lstrcatW( app, L"\winemenubuilder.exe" );
len = (lstrlenW( app ) + lstrlenW( args ) + 1) * sizeof(WCHAR); - buffer = heap_alloc( len ); + buffer = malloc( len ); if( !buffer ) return FALSE;
@@ -325,7 +325,7 @@ BOOL run_winemenubuilder( const WCHAR *args ) ret = CreateProcessW( app, buffer, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &si, &pi ); Wow64RevertWow64FsRedirection( redir );
- heap_free( buffer ); + free( buffer );
if (ret) { @@ -343,13 +343,13 @@ static BOOL StartLinkProcessor( LPCOLESTR szLink ) BOOL ret;
len = (lstrlenW( szLink ) + 7) * sizeof(WCHAR); - buffer = heap_alloc( len ); + buffer = malloc( len ); if( !buffer ) return FALSE;
swprintf( buffer, len, L" -w "%s"", szLink ); ret = run_winemenubuilder( buffer ); - heap_free( buffer ); + free( buffer ); return ret; }
@@ -383,8 +383,8 @@ static HRESULT WINAPI IPersistFile_fnSave(IPersistFile* iface, LPCOLESTR pszFile if (fRemember) { /* update file path */ - heap_free(This->filepath); - This->filepath = strdupW(pszFileName); + free(This->filepath); + This->filepath = wcsdup(pszFileName); }
This->bDirty = FALSE; @@ -516,14 +516,14 @@ static HRESULT Stream_LoadString( IStream* stm, BOOL unicode, LPWSTR *pstr ) len *= sizeof (WCHAR);
TRACE("reading %d\n", len); - temp = heap_alloc(len + sizeof(WCHAR)); + temp = malloc(len + sizeof(WCHAR)); if( !temp ) return E_OUTOFMEMORY; count = 0; r = IStream_Read(stm, temp, len, &count); if( FAILED (r) || ( count != len ) ) { - heap_free( temp ); + free( temp ); return E_FAIL; }
@@ -533,14 +533,14 @@ static HRESULT Stream_LoadString( IStream* stm, BOOL unicode, LPWSTR *pstr ) if( !unicode ) { count = MultiByteToWideChar( CP_ACP, 0, temp, len, NULL, 0 ); - str = heap_alloc( (count+1)*sizeof (WCHAR) ); + str = malloc( (count + 1) * sizeof(WCHAR) ); if( !str ) { - heap_free( temp ); + free( temp ); return E_OUTOFMEMORY; } MultiByteToWideChar( CP_ACP, 0, temp, len, str, count ); - heap_free( temp ); + free( temp ); } else { @@ -570,7 +570,7 @@ static HRESULT Stream_ReadChunk( IStream* stm, LPVOID *data ) if( FAILED( r ) || count != sizeof(size) ) return E_FAIL;
- chunk = heap_alloc( size ); + chunk = malloc( size ); if( !chunk ) return E_OUTOFMEMORY;
@@ -578,7 +578,7 @@ static HRESULT Stream_ReadChunk( IStream* stm, LPVOID *data ) r = IStream_Read( stm, chunk->data, size - sizeof(size), &count ); if( FAILED( r ) || count != (size - sizeof(size)) ) { - heap_free( chunk ); + free( chunk ); return E_FAIL; }
@@ -620,7 +620,7 @@ static LPWSTR Stream_LoadPath( LPCSTR p, DWORD maxlen ) len++;
wlen = MultiByteToWideChar(CP_ACP, 0, p, len, NULL, 0); - path = heap_alloc((wlen + 1) * sizeof(WCHAR)); + path = malloc((wlen + 1) * sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, p, len, path, wlen); path[wlen] = 0;
@@ -642,7 +642,7 @@ static HRESULT Stream_LoadLocation( IStream *stm, loc = (LOCATION_INFO*) p; if (loc->dwTotalSize < sizeof(LOCATION_INFO)) { - heap_free( p ); + free( p ); return E_FAIL; }
@@ -664,7 +664,7 @@ static HRESULT Stream_LoadLocation( IStream *stm, TRACE("type %ld serial %08lx name %s path %s\n", volume->type, volume->serial, debugstr_w(volume->label), debugstr_w(*path));
- heap_free( p ); + free( p ); return S_OK; }
@@ -718,7 +718,7 @@ static HRESULT Stream_LoadAdvertiseInfo( IStream* stm, LPWSTR *str ) return E_FAIL; }
- *str = heap_alloc((lstrlenW(buffer.szwDarwinID) + 1) * sizeof(WCHAR) ); + *str = malloc( (lstrlenW(buffer.szwDarwinID) + 1) * sizeof(WCHAR) ); lstrcpyW( *str, buffer.szwDarwinID );
return S_OK; @@ -760,21 +760,21 @@ static HRESULT WINAPI IPersistStream_fnLoad( ILFree(This->pPidl); This->pPidl = NULL; memset( &This->volume, 0, sizeof This->volume ); - heap_free(This->sPath); + free(This->sPath); This->sPath = NULL; - heap_free(This->sDescription); + free(This->sDescription); This->sDescription = NULL; - heap_free(This->sPathRel); + free(This->sPathRel); This->sPathRel = NULL; - heap_free(This->sWorkDir); + free(This->sWorkDir); This->sWorkDir = NULL; - heap_free(This->sArgs); + free(This->sArgs); This->sArgs = NULL; - heap_free(This->sIcoPath); + free(This->sIcoPath); This->sIcoPath = NULL; - heap_free(This->sProduct); + free(This->sProduct); This->sProduct = NULL; - heap_free(This->sComponent); + free(This->sComponent); This->sComponent = NULL;
This->wHotKey = hdr.wHotKey; @@ -941,7 +941,7 @@ static HRESULT Stream_WriteLocationInfo( IStream* stm, LPCWSTR path, total_size = sizeof *loc + volume_info_size + path_size + final_path_size;
/* create pointers to everything */ - loc = heap_alloc_zero(total_size); + loc = calloc(1, total_size); vol = (LOCAL_VOLUME_INFO*) &loc[1]; szLabel = (LPSTR) &vol[1]; szPath = &szLabel[label_size]; @@ -970,7 +970,7 @@ static HRESULT Stream_WriteLocationInfo( IStream* stm, LPCWSTR path, szFinalPath[0] = 0;
hr = IStream_Write( stm, loc, total_size, &count ); - heap_free(loc); + free(loc);
return hr; } @@ -1174,7 +1174,7 @@ static HRESULT ShellLink_UpdatePath(LPCWSTR sPathRel, LPCWSTR path, LPCWSTR sWor if (!*abs_path) lstrcpyW(abs_path, sPathRel);
- *psPath = heap_alloc((lstrlenW(abs_path) + 1) * sizeof(WCHAR)); + *psPath = malloc((lstrlenW(abs_path) + 1) * sizeof(WCHAR)); if (!*psPath) return E_OUTOFMEMORY;
@@ -1351,7 +1351,7 @@ static HRESULT WINAPI IShellLinkA_fnSetDescription(IShellLinkA *iface, LPCSTR ps descrW = NULL;
hr = IShellLinkW_SetDescription(&This->IShellLinkW_iface, descrW); - heap_free(descrW); + free(descrW);
return hr; } @@ -1384,7 +1384,7 @@ static HRESULT WINAPI IShellLinkA_fnSetWorkingDirectory(IShellLinkA *iface, LPCS if (!dirW) return E_OUTOFMEMORY;
hr = IShellLinkW_SetWorkingDirectory(&This->IShellLinkW_iface, dirW); - heap_free(dirW); + free(dirW);
return hr; } @@ -1421,7 +1421,7 @@ static HRESULT WINAPI IShellLinkA_fnSetArguments(IShellLinkA *iface, LPCSTR pszA argsW = NULL;
hr = IShellLinkW_SetArguments(&This->IShellLinkW_iface, argsW); - heap_free(argsW); + free(argsW);
return hr; } @@ -1483,7 +1483,7 @@ static HRESULT WINAPI IShellLinkA_fnSetIconLocation(IShellLinkA *iface, LPCSTR p }
hr = IShellLinkW_SetIconLocation(&This->IShellLinkW_iface, path ? pathW : NULL, icon); - heap_free(pathW); + free(pathW);
return hr; } @@ -1501,7 +1501,7 @@ static HRESULT WINAPI IShellLinkA_fnSetRelativePath(IShellLinkA *iface, LPCSTR p if (!pathW) return E_OUTOFMEMORY;
hr = IShellLinkW_SetRelativePath(&This->IShellLinkW_iface, pathW, dwReserved); - heap_free(pathW); + free(pathW);
return hr; } @@ -1530,7 +1530,7 @@ static HRESULT WINAPI IShellLinkA_fnSetPath(IShellLinkA *iface, LPCSTR pszFile) return E_OUTOFMEMORY;
r = IShellLinkW_SetPath(&This->IShellLinkW_iface, str); - heap_free( str ); + free( str );
return r; } @@ -1652,15 +1652,15 @@ static ULONG WINAPI IShellLinkW_fnRelease(IShellLinkW * iface)
TRACE("-- destroying IShellLink(%p)\n",This);
- heap_free(This->sIcoPath); - heap_free(This->sArgs); - heap_free(This->sWorkDir); - heap_free(This->sDescription); - heap_free(This->sPath); - heap_free(This->sPathRel); - heap_free(This->sProduct); - heap_free(This->sComponent); - heap_free(This->filepath); + free(This->sIcoPath); + free(This->sArgs); + free(This->sWorkDir); + free(This->sDescription); + free(This->sPath); + free(This->sPathRel); + free(This->sProduct); + free(This->sComponent); + free(This->filepath);
if (This->site) IUnknown_Release( This->site ); @@ -1754,12 +1754,12 @@ static HRESULT WINAPI IShellLinkW_fnSetIDList(IShellLinkW * iface, LPCITEMIDLIST if( !This->pPidl ) return E_FAIL;
- heap_free( This->sPath ); + free( This->sPath ); This->sPath = NULL;
if ( SHGetPathFromIDListW( pidl, path ) ) { - This->sPath = heap_alloc((lstrlenW(path) + 1) * sizeof(WCHAR)); + This->sPath = malloc((lstrlenW(path) + 1) * sizeof(WCHAR)); if (!This->sPath) return E_OUTOFMEMORY;
@@ -1790,10 +1790,10 @@ static HRESULT WINAPI IShellLinkW_fnSetDescription(IShellLinkW * iface, LPCWSTR
TRACE("(%p)->(desc=%s)\n",This, debugstr_w(pszName));
- heap_free(This->sDescription); + free(This->sDescription); if (pszName) { - This->sDescription = heap_alloc((lstrlenW( pszName )+1)*sizeof(WCHAR) ); + This->sDescription = malloc( (lstrlenW( pszName ) + 1) * sizeof(WCHAR) ); if ( !This->sDescription ) return E_OUTOFMEMORY;
@@ -1826,8 +1826,8 @@ static HRESULT WINAPI IShellLinkW_fnSetWorkingDirectory(IShellLinkW * iface, LPC
TRACE("(%p)->(dir=%s)\n",This, debugstr_w(pszDir));
- heap_free(This->sWorkDir); - This->sWorkDir = heap_alloc((lstrlenW( pszDir ) + 1) * sizeof (WCHAR) ); + free(This->sWorkDir); + This->sWorkDir = malloc( (lstrlenW( pszDir ) + 1) * sizeof(WCHAR) ); if ( !This->sWorkDir ) return E_OUTOFMEMORY; lstrcpyW( This->sWorkDir, pszDir ); @@ -1856,10 +1856,10 @@ static HRESULT WINAPI IShellLinkW_fnSetArguments(IShellLinkW * iface, LPCWSTR ps
TRACE("(%p)->(args=%s)\n",This, debugstr_w(pszArgs));
- heap_free(This->sArgs); + free(This->sArgs); if (pszArgs) { - This->sArgs = heap_alloc((lstrlenW( pszArgs )+1)*sizeof (WCHAR) ); + This->sArgs = malloc( (lstrlenW( pszArgs ) + 1) * sizeof(WCHAR) ); if ( !This->sArgs ) return E_OUTOFMEMORY; lstrcpyW( This->sArgs, pszArgs ); @@ -1939,11 +1939,11 @@ static HRESULT WINAPI IShellLinkW_fnSetIconLocation(IShellLinkW * iface, const W
TRACE("(%p)->(path=%s icon=%u)\n", This, debugstr_w(path), icon);
- heap_free(This->sIcoPath); + free(This->sIcoPath); if (path) { size_t len = (lstrlenW(path) + 1) * sizeof(WCHAR); - This->sIcoPath = heap_alloc(len); + This->sIcoPath = malloc(len); if (!This->sIcoPath) return E_OUTOFMEMORY; memcpy(This->sIcoPath, path, len); @@ -1962,8 +1962,8 @@ static HRESULT WINAPI IShellLinkW_fnSetRelativePath(IShellLinkW * iface, LPCWSTR
TRACE("(%p)->(path=%s %lx)\n",This, debugstr_w(pszPathRel), dwReserved);
- heap_free(This->sPathRel); - This->sPathRel = heap_alloc((lstrlenW( pszPathRel )+1) * sizeof (WCHAR) ); + free(This->sPathRel); + This->sPathRel = malloc( (lstrlenW( pszPathRel ) + 1) * sizeof(WCHAR) ); if ( !This->sPathRel ) return E_OUTOFMEMORY; lstrcpyW( This->sPathRel, pszPathRel ); @@ -1989,7 +1989,7 @@ static HRESULT WINAPI IShellLinkW_fnResolve(IShellLinkW * iface, HWND hwnd, DWOR bSuccess = SHGetPathFromIDListW(This->pPidl, buffer);
if (bSuccess && *buffer) { - This->sPath = heap_alloc((lstrlenW(buffer)+1)*sizeof(WCHAR)); + This->sPath = malloc((lstrlenW(buffer) + 1) * sizeof(WCHAR)); if (!This->sPath) return E_OUTOFMEMORY;
@@ -2001,7 +2001,7 @@ static HRESULT WINAPI IShellLinkW_fnResolve(IShellLinkW * iface, HWND hwnd, DWOR }
if (!This->sIcoPath && This->sPath) { - This->sIcoPath = heap_alloc((lstrlenW(This->sPath)+1)*sizeof(WCHAR)); + This->sIcoPath = malloc((lstrlenW(This->sPath) + 1) * sizeof(WCHAR)); if (!This->sIcoPath) return E_OUTOFMEMORY;
@@ -2027,7 +2027,7 @@ static LPWSTR ShellLink_GetAdvertisedArg(LPCWSTR str) if( !p ) return NULL; len = p - str; - ret = heap_alloc(sizeof(WCHAR)*(len+1)); + ret = malloc(sizeof(WCHAR) * (len + 1)); if( !ret ) return ret; memcpy( ret, str, sizeof(WCHAR)*len ); @@ -2127,7 +2127,7 @@ static HRESULT WINAPI IShellLinkW_fnSetPath(IShellLinkW * iface, LPCWSTR pszFile len = lstrlenW(pszFile); if (pszFile[0] == '"' && pszFile[len-1] == '"') { - unquoted = strdupW(pszFile); + unquoted = wcsdup(pszFile); PathUnquoteSpacesW(unquoted); pszFile = unquoted; } @@ -2135,14 +2135,14 @@ static HRESULT WINAPI IShellLinkW_fnSetPath(IShellLinkW * iface, LPCWSTR pszFile /* any other quote marks are invalid */ if (wcschr(pszFile, '"')) { - heap_free(unquoted); + free(unquoted); return S_FALSE; }
- heap_free(This->sPath); + free(This->sPath); This->sPath = NULL;
- heap_free(This->sComponent); + free(This->sComponent); This->sComponent = NULL;
if (This->pPidl) @@ -2155,7 +2155,7 @@ static HRESULT WINAPI IShellLinkW_fnSetPath(IShellLinkW * iface, LPCWSTR pszFile *buffer = '\0'; else if (!GetFullPathNameW(pszFile, MAX_PATH, buffer, &fname)) { - heap_free(unquoted); + free(unquoted); return E_FAIL; } else if(!PathFileExistsW(buffer) && @@ -2165,17 +2165,17 @@ static HRESULT WINAPI IShellLinkW_fnSetPath(IShellLinkW * iface, LPCWSTR pszFile This->pPidl = SHSimpleIDListFromPathW(pszFile); ShellLink_GetVolumeInfo(buffer, &This->volume);
- This->sPath = heap_alloc( (lstrlenW( buffer )+1) * sizeof (WCHAR) ); + This->sPath = malloc( (lstrlenW( buffer ) + 1) * sizeof(WCHAR) ); if (!This->sPath) { - heap_free(unquoted); + free(unquoted); return E_OUTOFMEMORY; }
lstrcpyW(This->sPath, buffer); } This->bDirty = TRUE; - heap_free(unquoted); + free(unquoted);
return hr; } @@ -2376,14 +2376,14 @@ ShellLink_ExtInit_Initialize( IShellExtInit* iface, LPCITEMIDLIST pidlFolder,
count = DragQueryFileW( stgm.u.hGlobal, 0, NULL, 0 ); count++; - path = heap_alloc(count*sizeof(WCHAR) ); + path = malloc( count * sizeof(WCHAR) ); if( path ) { IPersistFile *pf = &This->IPersistFile_iface;
count = DragQueryFileW( stgm.u.hGlobal, 0, path, count ); r = IPersistFile_Load( pf, path, 0 ); - heap_free( path ); + free( path ); } } ReleaseStgMedium( &stgm ); @@ -2460,11 +2460,11 @@ shelllink_get_msi_component_path( LPWSTR component ) return NULL;
sz++; - path = heap_alloc( sz*sizeof(WCHAR) ); + path = malloc( sz * sizeof(WCHAR) ); r = CommandLineFromMsiDescriptor( component, path, &sz ); if (r != ERROR_SUCCESS) { - heap_free( path ); + free( path ); path = NULL; }
@@ -2505,7 +2505,7 @@ ShellLink_InvokeCommand( IContextMenu* iface, LPCMINVOKECOMMANDINFO lpici ) return E_FAIL; } else - path = strdupW( This->sPath ); + path = wcsdup( This->sPath );
if ( lpici->cbSize == sizeof (CMINVOKECOMMANDINFOEX) && ( lpici->fMask & CMIC_MASK_UNICODE ) ) @@ -2518,7 +2518,7 @@ ShellLink_InvokeCommand( IContextMenu* iface, LPCMINVOKECOMMANDINFO lpici ) if ( iciex->lpParametersW ) len += lstrlenW( iciex->lpParametersW );
- args = heap_alloc( len*sizeof(WCHAR) ); + args = malloc( len * sizeof(WCHAR) ); args[0] = 0; if ( This->sArgs ) lstrcatW( args, This->sArgs ); @@ -2544,8 +2544,8 @@ ShellLink_InvokeCommand( IContextMenu* iface, LPCMINVOKECOMMANDINFO lpici ) else r = E_FAIL;
- heap_free( args ); - heap_free( path ); + free( args ); + free( path );
return r; }
On Thu Oct 20 15:14:34 2022 +0000, Alex Henrie wrote:
changed this line in [version 2 of the diff](/wine/wine/-/merge_requests/1103/diffs?diff_id=14755&start_sha=7a3337f1974461772fd7e64771fcb98e1dd9385f#9a4ac84dc468778e93eb77103cd874caaf76e44a_1250_1250)
Good point. I just changed this SHAlloc to malloc and the corresponding SHFree to free.
This merge request was approved by Huw Davies.