Module: wine Branch: master Commit: d34d0c1001db5c3ccb22c05770be2d7457c21e45 URL: https://gitlab.winehq.org/wine/wine/-/commit/d34d0c1001db5c3ccb22c05770be2d7...
Author: Alex Henrie alexhenrie24@gmail.com Date: Sun Nov 20 18:58:20 2022 -0700
appwiz: Use standard C functions for memory allocation.
---
dlls/appwiz.cpl/addons.c | 56 ++++++++++++++++++++++++------------------------ dlls/appwiz.cpl/appwiz.h | 21 ++---------------- 2 files changed, 30 insertions(+), 47 deletions(-)
diff --git a/dlls/appwiz.cpl/addons.c b/dlls/appwiz.cpl/addons.c index b815ffbb5cb..f7e36b8b99b 100644 --- a/dlls/appwiz.cpl/addons.c +++ b/dlls/appwiz.cpl/addons.c @@ -193,7 +193,7 @@ static enum install_res install_from_dos_file(const WCHAR *dir, const WCHAR *sub HRESULT hr;
size += lstrlenW( subdir ) + lstrlenW( file_name ) + 2; - if (!(path = heap_alloc( size * sizeof(WCHAR) ))) return INSTALL_FAILED; + if (!(path = malloc( size * sizeof(WCHAR) ))) return INSTALL_FAILED;
lstrcpyW( path, dir ); if (!wcsncmp( path, L"\??\", 4 )) path[1] = '\'; /* change ??\ into \?\ */ @@ -207,10 +207,10 @@ static enum install_res install_from_dos_file(const WCHAR *dir, const WCHAR *sub if (FAILED( hr )) { ERR( "Failed to canonicalize %s, hr %#lx\n", debugstr_w(path), hr ); - heap_free( path ); + free( path ); return INSTALL_NEXT; } - heap_free( path ); + free( path );
if (GetFileAttributesW( canonical_path ) == INVALID_FILE_ATTRIBUTES) { @@ -233,7 +233,7 @@ static enum install_res install_from_unix_file(const char *dir, const WCHAR *sub if (p_wine_get_dos_file_name && (dos_dir = p_wine_get_dos_file_name( dir ))) { ret = install_from_dos_file( dos_dir, subdir, file_name ); - heap_free( dos_dir ); + free( dos_dir ); } return ret; } @@ -264,24 +264,24 @@ static enum install_res install_from_registered_dir(void) if(!hkey) return INSTALL_NEXT;
- package_dir = heap_alloc(size); + package_dir = malloc(size); res = RegGetValueA(hkey, NULL, addon->dir_config_key, RRF_RT_ANY, &type, (PBYTE)package_dir, &size); if(res == ERROR_MORE_DATA) { - package_dir = heap_realloc(package_dir, size); + package_dir = realloc(package_dir, size); res = RegGetValueA(hkey, NULL, addon->dir_config_key, RRF_RT_ANY, &type, (PBYTE)package_dir, &size); } RegCloseKey(hkey); if(res == ERROR_FILE_NOT_FOUND) { - heap_free(package_dir); + free(package_dir); return INSTALL_NEXT; } else if(res != ERROR_SUCCESS || (type != REG_SZ && type != REG_EXPAND_SZ)) { - heap_free(package_dir); + free(package_dir); return INSTALL_FAILED; }
ret = install_from_unix_file(package_dir, L"", addon->file_name);
- heap_free(package_dir); + free(package_dir); return ret; }
@@ -293,7 +293,7 @@ static enum install_res install_from_default_dir(void)
if ((package_dir = _wgetenv( L"WINEBUILDDIR" ))) { - dir_buf = heap_alloc( lstrlenW(package_dir) * sizeof(WCHAR) + sizeof(L"\..\") ); + dir_buf = malloc( wcslen(package_dir) * sizeof(WCHAR) + sizeof(L"\..\") ); lstrcpyW( dir_buf, package_dir ); lstrcatW( dir_buf, L"\..\" ); package_dir = dir_buf; @@ -303,7 +303,7 @@ static enum install_res install_from_default_dir(void) if (package_dir) { ret = install_from_dos_file(package_dir, addon->subdir_name, addon->file_name); - heap_free(dir_buf); + free(dir_buf); }
if (ret == INSTALL_NEXT) @@ -329,7 +329,7 @@ static WCHAR *get_cache_file_name(BOOL ensure_exists) } else if ((home_dir = _wgetenv( L"WINEHOMEDIR" ))) { - if (!(cache_dir = heap_alloc( lstrlenW(home_dir) * sizeof(WCHAR) + sizeof(L"\.cache") ))) return NULL; + if (!(cache_dir = malloc( wcslen(home_dir) * sizeof(WCHAR) + sizeof(L"\.cache") ))) return NULL; lstrcpyW( cache_dir, home_dir ); lstrcatW( cache_dir, L"\.cache" ); cache_dir[1] = '\'; /* change ??\ into \?\ */ @@ -339,24 +339,24 @@ static WCHAR *get_cache_file_name(BOOL ensure_exists) if (ensure_exists && !CreateDirectoryW( cache_dir, NULL ) && GetLastError() != ERROR_ALREADY_EXISTS) { WARN( "%s does not exist and could not be created (%lu)\n", debugstr_w(cache_dir), GetLastError() ); - heap_free( cache_dir ); + free( cache_dir ); return NULL; }
size = lstrlenW( cache_dir ) + ARRAY_SIZE(L"\wine") + lstrlenW( addon->file_name ) + 1; - if (!(ret = heap_alloc( size * sizeof(WCHAR) ))) + if (!(ret = malloc( size * sizeof(WCHAR) ))) { - heap_free( cache_dir ); + free( cache_dir ); return NULL; } lstrcpyW( ret, cache_dir ); lstrcatW( ret, L"\wine" ); - heap_free( cache_dir ); + free( cache_dir );
if (ensure_exists && !CreateDirectoryW( ret, NULL ) && GetLastError() != ERROR_ALREADY_EXISTS) { WARN( "%s does not exist and could not be created (%lu)\n", debugstr_w(ret), GetLastError() ); - heap_free( ret ); + free( ret ); return NULL; } len = lstrlenW( ret ); @@ -379,12 +379,12 @@ static enum install_res install_from_cache(void) if(!sha_check(cache_file_name)) { WARN("could not validate checksum\n"); DeleteFileW(cache_file_name); - heap_free(cache_file_name); + free(cache_file_name); return INSTALL_NEXT; }
res = install_file(cache_file_name); - heap_free(cache_file_name); + free(cache_file_name); return res; }
@@ -485,7 +485,7 @@ static HRESULT WINAPI InstallCallback_OnStopBinding(IBindStatusCallback *iface, cache_file_name = get_cache_file_name(TRUE); if(cache_file_name) { CopyFileW(msi_file, cache_file_name, FALSE); - heap_free(cache_file_name); + free(cache_file_name); } }else { WCHAR message[256]; @@ -495,7 +495,7 @@ static HRESULT WINAPI InstallCallback_OnStopBinding(IBindStatusCallback *iface, }
DeleteFileW(msi_file); - heap_free(msi_file); + free(msi_file); msi_file = NULL;
EndDialog(install_dialog, 0); @@ -515,7 +515,7 @@ static HRESULT WINAPI InstallCallback_OnDataAvailable(IBindStatusCallback *iface DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed) { if(!msi_file) { - msi_file = heap_strdupW(pstgmed->u.lpszFileName); + msi_file = wcsdup(pstgmed->u.lpszFileName); TRACE("got file name %s\n", debugstr_w(msi_file)); }
@@ -622,15 +622,15 @@ static LPWSTR get_url(void)
static const WCHAR httpW[] = {'h','t','t','p'};
- url = heap_alloc(size); + url = malloc(size); returned_size = size;
hkey = open_config_key(); if (hkey) { - config_key = heap_strdupAtoW(addon->url_config_key); + config_key = strdupAtoW(addon->url_config_key); res = RegQueryValueExW(hkey, config_key, NULL, &type, (LPBYTE)url, &returned_size); - heap_free(config_key); + free(config_key); RegCloseKey(hkey); if(res == ERROR_SUCCESS && type == REG_SZ) goto found; } @@ -684,7 +684,7 @@ static void run_winebrowser(const WCHAR *url) lstrcpyW(app+len, L"\winebrowser.exe"); len += ARRAY_SIZE(L"\winebrowser.exe") - 1;
- args = heap_alloc((len+1+url_len)*sizeof(WCHAR)); + args = malloc((len + 1 + url_len) * sizeof(WCHAR)); if(!args) return;
@@ -697,7 +697,7 @@ static void run_winebrowser(const WCHAR *url) memset(&si, 0, sizeof(si)); si.cb = sizeof(si); ret = CreateProcessW(app, args, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &si, &pi); - heap_free(args); + free(args); if (ret) { CloseHandle(pi.hThread); CloseHandle(pi.hProcess); @@ -766,7 +766,7 @@ BOOL install_addon(addon_t addon_type) && (url = get_url())) DialogBoxW(hInst, addon->dialog_template, 0, installer_proc);
- heap_free(url); + free(url); url = NULL; return TRUE; } diff --git a/dlls/appwiz.cpl/appwiz.h b/dlls/appwiz.cpl/appwiz.h index ac8b5427d98..c6562e78cba 100644 --- a/dlls/appwiz.cpl/appwiz.h +++ b/dlls/appwiz.cpl/appwiz.h @@ -16,7 +16,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#include "wine/heap.h" #include "winnls.h"
typedef enum { @@ -28,23 +27,7 @@ BOOL install_addon(addon_t) DECLSPEC_HIDDEN;
extern HINSTANCE hInst DECLSPEC_HIDDEN;
-static inline WCHAR *heap_strdupW(const WCHAR *str) -{ - WCHAR *ret; - - if(str) { - size_t size = lstrlenW(str)+1; - ret = heap_alloc(size*sizeof(WCHAR)); - if(ret) - memcpy(ret, str, size*sizeof(WCHAR)); - }else { - ret = NULL; - } - - return ret; -} - -static inline WCHAR *heap_strdupAtoW(const char *str) +static inline WCHAR *strdupAtoW(const char *str) { WCHAR *ret = NULL;
@@ -52,7 +35,7 @@ static inline WCHAR *heap_strdupAtoW(const char *str) size_t len;
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); }