wineboot: Use CRT allocation functions.

This commit is contained in:
Alex Henrie 2023-09-07 19:12:10 -06:00 committed by Alexandre Julliard
parent 58e62fff58
commit dab59ded27
2 changed files with 35 additions and 37 deletions

View file

@ -50,8 +50,7 @@ static BOOL CALLBACK enum_proc( HWND hwnd, LPARAM lp )
if (win_count >= win_max)
{
UINT new_count = win_max * 2;
struct window_info *new_win = HeapReAlloc( GetProcessHeap(), 0, windows,
new_count * sizeof(windows[0]) );
struct window_info *new_win = realloc( windows, new_count * sizeof(windows[0]) );
if (!new_win) return FALSE;
windows = new_win;
win_max = new_count;
@ -77,7 +76,7 @@ static BOOL get_all_windows(void)
{
win_count = 0;
win_max = 16;
windows = HeapAlloc( GetProcessHeap(), 0, win_max * sizeof(windows[0]) );
windows = malloc( win_max * sizeof(windows[0]) );
if (!windows) return FALSE;
if (!EnumWindows( enum_proc, 0 )) return FALSE;
/* sort windows by processes */
@ -114,7 +113,7 @@ static void CALLBACK end_session_message_callback( HWND hwnd, UINT msg, ULONG_PT
/* cheap way of ref-counting callback_data whilst freeing memory at correct
* time */
if (!(cb_data->window_count--) && cb_data->timed_out)
HeapFree( GetProcessHeap(), 0, cb_data );
free( cb_data );
}
struct endtask_dlg_data
@ -175,7 +174,7 @@ static LRESULT send_messages_with_timeout_dialog(
struct endtask_dlg_data dlg_data;
LRESULT result;
cb_data = HeapAlloc( GetProcessHeap(), 0, sizeof(*cb_data) );
cb_data = malloc( sizeof(*cb_data) );
if (!cb_data)
return 1;
@ -204,7 +203,7 @@ static LRESULT send_messages_with_timeout_dialog(
QS_ALLINPUT );
if (ret == WAIT_OBJECT_0) /* process exited */
{
HeapFree( GetProcessHeap(), 0, cb_data );
free( cb_data );
result = 1;
goto cleanup;
}
@ -222,7 +221,7 @@ static LRESULT send_messages_with_timeout_dialog(
if (!cb_data->window_count)
{
result = dlg_data.terminated || cb_data->result;
HeapFree( GetProcessHeap(), 0, cb_data );
free( cb_data );
if (!result)
goto cleanup;
break;
@ -327,7 +326,7 @@ BOOL shutdown_close_windows( BOOL force )
if (n && result)
result = send_end_session_messages( windows + win_count - n, n, send_flags );
HeapFree( GetProcessHeap(), 0, windows );
free( windows );
return (result != 0);
}

View file

@ -96,15 +96,14 @@ static WCHAR *get_wine_inf_path(void)
if ((dir = _wgetenv( L"WINEBUILDDIR" )))
{
if (!(name = HeapAlloc( GetProcessHeap(), 0,
sizeof(L"\\loader\\wine.inf") + lstrlenW(dir) * sizeof(WCHAR) )))
if (!(name = malloc( sizeof(L"\\loader\\wine.inf") + wcslen(dir) * sizeof(WCHAR) )))
return NULL;
lstrcpyW( name, dir );
lstrcatW( name, L"\\loader" );
}
else if ((dir = _wgetenv( L"WINEDATADIR" )))
{
if (!(name = HeapAlloc( GetProcessHeap(), 0, sizeof(L"\\wine.inf") + lstrlenW(dir) * sizeof(WCHAR) )))
if (!(name = malloc( sizeof(L"\\wine.inf") + wcslen(dir) * sizeof(WCHAR) )))
return NULL;
lstrcpyW( name, dir );
}
@ -121,7 +120,7 @@ static BOOL update_timestamp( const WCHAR *config_dir, unsigned long timestamp )
BOOL ret = FALSE;
int fd, count;
char buffer[100];
WCHAR *file = HeapAlloc( GetProcessHeap(), 0, lstrlenW(config_dir) * sizeof(WCHAR) + sizeof(L"\\.update-timestamp") );
WCHAR *file = malloc( wcslen(config_dir) * sizeof(WCHAR) + sizeof(L"\\.update-timestamp") );
if (!file) return FALSE;
lstrcpyW( file, config_dir );
@ -154,7 +153,7 @@ static BOOL update_timestamp( const WCHAR *config_dir, unsigned long timestamp )
done:
if (fd != -1) close( fd );
HeapFree( GetProcessHeap(), 0, file );
free( file );
return ret;
}
@ -539,7 +538,7 @@ static inline WCHAR *heap_strdupAW( const char *src )
WCHAR *dst;
if (!src) return NULL;
len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 );
if ((dst = HeapAlloc( GetProcessHeap(), 0, len * sizeof(*dst) ))) MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len );
if ((dst = malloc( len * sizeof(*dst) ))) MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len );
return dst;
}
@ -562,7 +561,7 @@ static void set_value_from_smbios_string( HKEY key, const WCHAR *value, BYTE id,
WCHAR *str;
str = get_smbios_string( id, buf, offset, buflen );
set_reg_value( key, value, str ? str : L"" );
HeapFree( GetProcessHeap(), 0, str );
free( str );
}
static void create_bios_baseboard_values( HKEY bios_key, const char *buf, UINT len )
@ -647,7 +646,7 @@ static void create_bios_key( HKEY system_key )
return;
len = GetSystemFirmwareTable( RSMB, 0, NULL, 0 );
if (!(buf = HeapAlloc( GetProcessHeap(), 0, len ))) goto done;
if (!(buf = malloc( len ))) goto done;
len = GetSystemFirmwareTable( RSMB, 0, buf, len );
create_bios_baseboard_values( bios_key, buf, len );
@ -655,7 +654,7 @@ static void create_bios_key( HKEY system_key )
create_bios_system_values( bios_key, buf, len );
done:
HeapFree( GetProcessHeap(), 0, buf );
free( buf );
RegCloseKey( bios_key );
}
@ -675,7 +674,7 @@ static void create_hardware_registry_keys(void)
if (NtQuerySystemInformation( SystemProcessorBrandString, name_buffer, sizeof(name_buffer), NULL ))
name_buffer[0] = 0;
power_info = HeapAlloc( GetProcessHeap(), 0, sizeof_power_info );
power_info = malloc( sizeof_power_info );
if (power_info == NULL)
return;
if (NtPowerInformation( ProcessorInformation, NULL, 0, power_info, sizeof_power_info ))
@ -702,7 +701,7 @@ static void create_hardware_registry_keys(void)
if (RegCreateKeyExW( HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System", 0, NULL,
REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &system_key, NULL ))
{
HeapFree( GetProcessHeap(), 0, power_info );
free( power_info );
return;
}
@ -761,7 +760,7 @@ static void create_hardware_registry_keys(void)
RegCloseKey( fpu_key );
RegCloseKey( cpu_key );
RegCloseKey( system_key );
HeapFree( GetProcessHeap(), 0, power_info );
free( power_info );
}
@ -934,9 +933,9 @@ static BOOL wininit(void)
{
if (!(res = GetPrivateProfileSectionW( L"rename", buffer, size, L"wininit.ini" ))) return TRUE;
if (res < size - 2) break;
if (buffer != initial_buffer) HeapFree( GetProcessHeap(), 0, buffer );
if (buffer != initial_buffer) free( buffer );
size *= 2;
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) ))) return FALSE;
if (!(buffer = malloc( size * sizeof(WCHAR) ))) return FALSE;
}
for (str = buffer; *str; str += lstrlenW(str) + 1)
@ -965,7 +964,7 @@ static BOOL wininit(void)
str = value;
}
if (buffer != initial_buffer) HeapFree( GetProcessHeap(), 0, buffer );
if (buffer != initial_buffer) free( buffer );
if( !MoveFileExW( L"wininit.ini", L"wininit.bak", MOVEFILE_REPLACE_EXISTING) )
{
@ -990,7 +989,7 @@ static void pendingRename(void)
if (RegQueryValueExW( hSession, L"PendingFileRenameOperations", NULL, NULL, NULL, &dataLength ))
goto end;
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, dataLength ))) goto end;
if (!(buffer = malloc( dataLength ))) goto end;
if (RegQueryValueExW( hSession, L"PendingFileRenameOperations", NULL, NULL,
(LPBYTE)buffer, &dataLength ))
@ -1038,7 +1037,7 @@ static void pendingRename(void)
RegDeleteValueW(hSession, L"PendingFileRenameOperations");
end:
HeapFree(GetProcessHeap(), 0, buffer);
free( buffer );
RegCloseKey( hSession );
}
@ -1112,12 +1111,12 @@ static void process_run_key( HKEY key, const WCHAR *keyname, BOOL delete, BOOL s
WINE_TRACE( "No commands to execute.\n" );
goto end;
}
if (!(cmdline = HeapAlloc( GetProcessHeap(), 0, max_cmdline )))
if (!(cmdline = malloc( max_cmdline )))
{
WINE_ERR( "Couldn't allocate memory for the commands to be executed.\n" );
goto end;
}
if (!(value = HeapAlloc( GetProcessHeap(), 0, ++max_value * sizeof(*value) )))
if (!(value = malloc( ++max_value * sizeof(*value) )))
{
WINE_ERR( "Couldn't allocate memory for the value names.\n" );
goto end;
@ -1149,8 +1148,8 @@ static void process_run_key( HKEY key, const WCHAR *keyname, BOOL delete, BOOL s
}
end:
HeapFree( GetProcessHeap(), 0, value );
HeapFree( GetProcessHeap(), 0, cmdline );
free( value );
free( cmdline );
RegCloseKey( runkey );
WINE_TRACE( "Done.\n" );
}
@ -1220,7 +1219,7 @@ static int ProcessWindowsFileProtection(void)
if (!RegQueryValueExW( hkey, L"SFCDllCacheDir", 0, NULL, NULL, &sz))
{
sz += sizeof(WCHAR);
dllcache = HeapAlloc(GetProcessHeap(),0,sz + sizeof(L"\\*"));
dllcache = malloc( sz + sizeof(L"\\*") );
RegQueryValueExW( hkey, L"SFCDllCacheDir", 0, NULL, (LPBYTE)dllcache, &sz);
lstrcatW( dllcache, L"\\*" );
}
@ -1230,7 +1229,7 @@ static int ProcessWindowsFileProtection(void)
if (!dllcache)
{
DWORD sz = GetSystemDirectoryW( NULL, 0 );
dllcache = HeapAlloc( GetProcessHeap(), 0, sz * sizeof(WCHAR) + sizeof(L"\\dllcache\\*"));
dllcache = malloc( sz * sizeof(WCHAR) + sizeof(L"\\dllcache\\*") );
GetSystemDirectoryW( dllcache, sz );
lstrcatW( dllcache, L"\\dllcache\\*" );
}
@ -1276,7 +1275,7 @@ static int ProcessWindowsFileProtection(void)
find_rc = FindNextFileW(find_handle,&finddata);
}
FindClose(find_handle);
HeapFree(GetProcessHeap(),0,dllcache);
free(dllcache);
return 1;
}
@ -1327,10 +1326,10 @@ static INT_PTR CALLBACK wait_dlgproc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp
SendDlgItemMessageW( hwnd, IDC_WAITICON, STM_SETICON, (WPARAM)icon, 0 );
SendDlgItemMessageW( hwnd, IDC_WAITTEXT, WM_GETTEXT, 1024, (LPARAM)text );
len = lstrlenW(text) + lstrlenW(name) + 1;
buffer = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
buffer = malloc( len * sizeof(WCHAR) );
swprintf( buffer, len, text, name );
SendDlgItemMessageW( hwnd, IDC_WAITTEXT, WM_SETTEXT, 0, (LPARAM)buffer );
HeapFree( GetProcessHeap(), 0, buffer );
free( buffer );
}
break;
}
@ -1362,7 +1361,7 @@ static HANDLE start_rundll32( const WCHAR *inf_path, const WCHAR *install, WORD
len = lstrlenW(app) + ARRAY_SIZE(L" setupapi,InstallHinfSection DefaultInstall 128 ") + lstrlenW(inf_path);
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return 0;
if (!(buffer = malloc( len * sizeof(WCHAR) ))) return 0;
swprintf( buffer, len, L"%s setupapi,InstallHinfSection %s 128 %s", app, install, inf_path );
if (CreateProcessW( app, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ))
@ -1370,7 +1369,7 @@ static HANDLE start_rundll32( const WCHAR *inf_path, const WCHAR *install, WORD
else
pi.hProcess = 0;
HeapFree( GetProcessHeap(), 0, buffer );
free( buffer );
return pi.hProcess;
}
@ -1525,7 +1524,7 @@ static void update_wineprefix( BOOL force )
}
done:
HeapFree( GetProcessHeap(), 0, inf_path );
free( inf_path );
}
/* Process items in the StartUp group of the user's Programs under the Start Menu. Some installers put