Commit dab59ded authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

wineboot: Use CRT allocation functions.

parent 58e62fff
...@@ -50,8 +50,7 @@ static BOOL CALLBACK enum_proc( HWND hwnd, LPARAM lp ) ...@@ -50,8 +50,7 @@ static BOOL CALLBACK enum_proc( HWND hwnd, LPARAM lp )
if (win_count >= win_max) if (win_count >= win_max)
{ {
UINT new_count = win_max * 2; UINT new_count = win_max * 2;
struct window_info *new_win = HeapReAlloc( GetProcessHeap(), 0, windows, struct window_info *new_win = realloc( windows, new_count * sizeof(windows[0]) );
new_count * sizeof(windows[0]) );
if (!new_win) return FALSE; if (!new_win) return FALSE;
windows = new_win; windows = new_win;
win_max = new_count; win_max = new_count;
...@@ -77,7 +76,7 @@ static BOOL get_all_windows(void) ...@@ -77,7 +76,7 @@ static BOOL get_all_windows(void)
{ {
win_count = 0; win_count = 0;
win_max = 16; win_max = 16;
windows = HeapAlloc( GetProcessHeap(), 0, win_max * sizeof(windows[0]) ); windows = malloc( win_max * sizeof(windows[0]) );
if (!windows) return FALSE; if (!windows) return FALSE;
if (!EnumWindows( enum_proc, 0 )) return FALSE; if (!EnumWindows( enum_proc, 0 )) return FALSE;
/* sort windows by processes */ /* sort windows by processes */
...@@ -114,7 +113,7 @@ static void CALLBACK end_session_message_callback( HWND hwnd, UINT msg, ULONG_PT ...@@ -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 /* cheap way of ref-counting callback_data whilst freeing memory at correct
* time */ * time */
if (!(cb_data->window_count--) && cb_data->timed_out) if (!(cb_data->window_count--) && cb_data->timed_out)
HeapFree( GetProcessHeap(), 0, cb_data ); free( cb_data );
} }
struct endtask_dlg_data struct endtask_dlg_data
...@@ -175,7 +174,7 @@ static LRESULT send_messages_with_timeout_dialog( ...@@ -175,7 +174,7 @@ static LRESULT send_messages_with_timeout_dialog(
struct endtask_dlg_data dlg_data; struct endtask_dlg_data dlg_data;
LRESULT result; LRESULT result;
cb_data = HeapAlloc( GetProcessHeap(), 0, sizeof(*cb_data) ); cb_data = malloc( sizeof(*cb_data) );
if (!cb_data) if (!cb_data)
return 1; return 1;
...@@ -204,7 +203,7 @@ static LRESULT send_messages_with_timeout_dialog( ...@@ -204,7 +203,7 @@ static LRESULT send_messages_with_timeout_dialog(
QS_ALLINPUT ); QS_ALLINPUT );
if (ret == WAIT_OBJECT_0) /* process exited */ if (ret == WAIT_OBJECT_0) /* process exited */
{ {
HeapFree( GetProcessHeap(), 0, cb_data ); free( cb_data );
result = 1; result = 1;
goto cleanup; goto cleanup;
} }
...@@ -222,7 +221,7 @@ static LRESULT send_messages_with_timeout_dialog( ...@@ -222,7 +221,7 @@ static LRESULT send_messages_with_timeout_dialog(
if (!cb_data->window_count) if (!cb_data->window_count)
{ {
result = dlg_data.terminated || cb_data->result; result = dlg_data.terminated || cb_data->result;
HeapFree( GetProcessHeap(), 0, cb_data ); free( cb_data );
if (!result) if (!result)
goto cleanup; goto cleanup;
break; break;
...@@ -327,7 +326,7 @@ BOOL shutdown_close_windows( BOOL force ) ...@@ -327,7 +326,7 @@ BOOL shutdown_close_windows( BOOL force )
if (n && result) if (n && result)
result = send_end_session_messages( windows + win_count - n, n, send_flags ); result = send_end_session_messages( windows + win_count - n, n, send_flags );
HeapFree( GetProcessHeap(), 0, windows ); free( windows );
return (result != 0); return (result != 0);
} }
......
...@@ -96,15 +96,14 @@ static WCHAR *get_wine_inf_path(void) ...@@ -96,15 +96,14 @@ static WCHAR *get_wine_inf_path(void)
if ((dir = _wgetenv( L"WINEBUILDDIR" ))) if ((dir = _wgetenv( L"WINEBUILDDIR" )))
{ {
if (!(name = HeapAlloc( GetProcessHeap(), 0, if (!(name = malloc( sizeof(L"\\loader\\wine.inf") + wcslen(dir) * sizeof(WCHAR) )))
sizeof(L"\\loader\\wine.inf") + lstrlenW(dir) * sizeof(WCHAR) )))
return NULL; return NULL;
lstrcpyW( name, dir ); lstrcpyW( name, dir );
lstrcatW( name, L"\\loader" ); lstrcatW( name, L"\\loader" );
} }
else if ((dir = _wgetenv( L"WINEDATADIR" ))) 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; return NULL;
lstrcpyW( name, dir ); lstrcpyW( name, dir );
} }
...@@ -121,7 +120,7 @@ static BOOL update_timestamp( const WCHAR *config_dir, unsigned long timestamp ) ...@@ -121,7 +120,7 @@ static BOOL update_timestamp( const WCHAR *config_dir, unsigned long timestamp )
BOOL ret = FALSE; BOOL ret = FALSE;
int fd, count; int fd, count;
char buffer[100]; 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; if (!file) return FALSE;
lstrcpyW( file, config_dir ); lstrcpyW( file, config_dir );
...@@ -154,7 +153,7 @@ static BOOL update_timestamp( const WCHAR *config_dir, unsigned long timestamp ) ...@@ -154,7 +153,7 @@ static BOOL update_timestamp( const WCHAR *config_dir, unsigned long timestamp )
done: done:
if (fd != -1) close( fd ); if (fd != -1) close( fd );
HeapFree( GetProcessHeap(), 0, file ); free( file );
return ret; return ret;
} }
...@@ -539,7 +538,7 @@ static inline WCHAR *heap_strdupAW( const char *src ) ...@@ -539,7 +538,7 @@ static inline WCHAR *heap_strdupAW( const char *src )
WCHAR *dst; WCHAR *dst;
if (!src) return NULL; if (!src) return NULL;
len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 ); 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; return dst;
} }
...@@ -562,7 +561,7 @@ static void set_value_from_smbios_string( HKEY key, const WCHAR *value, BYTE id, ...@@ -562,7 +561,7 @@ static void set_value_from_smbios_string( HKEY key, const WCHAR *value, BYTE id,
WCHAR *str; WCHAR *str;
str = get_smbios_string( id, buf, offset, buflen ); str = get_smbios_string( id, buf, offset, buflen );
set_reg_value( key, value, str ? str : L"" ); 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 ) 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 ) ...@@ -647,7 +646,7 @@ static void create_bios_key( HKEY system_key )
return; return;
len = GetSystemFirmwareTable( RSMB, 0, NULL, 0 ); 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 ); len = GetSystemFirmwareTable( RSMB, 0, buf, len );
create_bios_baseboard_values( bios_key, buf, len ); create_bios_baseboard_values( bios_key, buf, len );
...@@ -655,7 +654,7 @@ static void create_bios_key( HKEY system_key ) ...@@ -655,7 +654,7 @@ static void create_bios_key( HKEY system_key )
create_bios_system_values( bios_key, buf, len ); create_bios_system_values( bios_key, buf, len );
done: done:
HeapFree( GetProcessHeap(), 0, buf ); free( buf );
RegCloseKey( bios_key ); RegCloseKey( bios_key );
} }
...@@ -675,7 +674,7 @@ static void create_hardware_registry_keys(void) ...@@ -675,7 +674,7 @@ static void create_hardware_registry_keys(void)
if (NtQuerySystemInformation( SystemProcessorBrandString, name_buffer, sizeof(name_buffer), NULL )) if (NtQuerySystemInformation( SystemProcessorBrandString, name_buffer, sizeof(name_buffer), NULL ))
name_buffer[0] = 0; name_buffer[0] = 0;
power_info = HeapAlloc( GetProcessHeap(), 0, sizeof_power_info ); power_info = malloc( sizeof_power_info );
if (power_info == NULL) if (power_info == NULL)
return; return;
if (NtPowerInformation( ProcessorInformation, NULL, 0, power_info, sizeof_power_info )) if (NtPowerInformation( ProcessorInformation, NULL, 0, power_info, sizeof_power_info ))
...@@ -702,7 +701,7 @@ static void create_hardware_registry_keys(void) ...@@ -702,7 +701,7 @@ static void create_hardware_registry_keys(void)
if (RegCreateKeyExW( HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System", 0, NULL, if (RegCreateKeyExW( HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System", 0, NULL,
REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &system_key, NULL )) REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &system_key, NULL ))
{ {
HeapFree( GetProcessHeap(), 0, power_info ); free( power_info );
return; return;
} }
...@@ -761,7 +760,7 @@ static void create_hardware_registry_keys(void) ...@@ -761,7 +760,7 @@ static void create_hardware_registry_keys(void)
RegCloseKey( fpu_key ); RegCloseKey( fpu_key );
RegCloseKey( cpu_key ); RegCloseKey( cpu_key );
RegCloseKey( system_key ); RegCloseKey( system_key );
HeapFree( GetProcessHeap(), 0, power_info ); free( power_info );
} }
...@@ -934,9 +933,9 @@ static BOOL wininit(void) ...@@ -934,9 +933,9 @@ static BOOL wininit(void)
{ {
if (!(res = GetPrivateProfileSectionW( L"rename", buffer, size, L"wininit.ini" ))) return TRUE; if (!(res = GetPrivateProfileSectionW( L"rename", buffer, size, L"wininit.ini" ))) return TRUE;
if (res < size - 2) break; if (res < size - 2) break;
if (buffer != initial_buffer) HeapFree( GetProcessHeap(), 0, buffer ); if (buffer != initial_buffer) free( buffer );
size *= 2; 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) for (str = buffer; *str; str += lstrlenW(str) + 1)
...@@ -965,7 +964,7 @@ static BOOL wininit(void) ...@@ -965,7 +964,7 @@ static BOOL wininit(void)
str = value; 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) ) if( !MoveFileExW( L"wininit.ini", L"wininit.bak", MOVEFILE_REPLACE_EXISTING) )
{ {
...@@ -990,7 +989,7 @@ static void pendingRename(void) ...@@ -990,7 +989,7 @@ static void pendingRename(void)
if (RegQueryValueExW( hSession, L"PendingFileRenameOperations", NULL, NULL, NULL, &dataLength )) if (RegQueryValueExW( hSession, L"PendingFileRenameOperations", NULL, NULL, NULL, &dataLength ))
goto end; goto end;
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, dataLength ))) goto end; if (!(buffer = malloc( dataLength ))) goto end;
if (RegQueryValueExW( hSession, L"PendingFileRenameOperations", NULL, NULL, if (RegQueryValueExW( hSession, L"PendingFileRenameOperations", NULL, NULL,
(LPBYTE)buffer, &dataLength )) (LPBYTE)buffer, &dataLength ))
...@@ -1038,7 +1037,7 @@ static void pendingRename(void) ...@@ -1038,7 +1037,7 @@ static void pendingRename(void)
RegDeleteValueW(hSession, L"PendingFileRenameOperations"); RegDeleteValueW(hSession, L"PendingFileRenameOperations");
end: end:
HeapFree(GetProcessHeap(), 0, buffer); free( buffer );
RegCloseKey( hSession ); RegCloseKey( hSession );
} }
...@@ -1112,12 +1111,12 @@ static void process_run_key( HKEY key, const WCHAR *keyname, BOOL delete, BOOL s ...@@ -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" ); WINE_TRACE( "No commands to execute.\n" );
goto end; 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" ); WINE_ERR( "Couldn't allocate memory for the commands to be executed.\n" );
goto end; 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" ); WINE_ERR( "Couldn't allocate memory for the value names.\n" );
goto end; goto end;
...@@ -1149,8 +1148,8 @@ static void process_run_key( HKEY key, const WCHAR *keyname, BOOL delete, BOOL s ...@@ -1149,8 +1148,8 @@ static void process_run_key( HKEY key, const WCHAR *keyname, BOOL delete, BOOL s
} }
end: end:
HeapFree( GetProcessHeap(), 0, value ); free( value );
HeapFree( GetProcessHeap(), 0, cmdline ); free( cmdline );
RegCloseKey( runkey ); RegCloseKey( runkey );
WINE_TRACE( "Done.\n" ); WINE_TRACE( "Done.\n" );
} }
...@@ -1220,7 +1219,7 @@ static int ProcessWindowsFileProtection(void) ...@@ -1220,7 +1219,7 @@ static int ProcessWindowsFileProtection(void)
if (!RegQueryValueExW( hkey, L"SFCDllCacheDir", 0, NULL, NULL, &sz)) if (!RegQueryValueExW( hkey, L"SFCDllCacheDir", 0, NULL, NULL, &sz))
{ {
sz += sizeof(WCHAR); sz += sizeof(WCHAR);
dllcache = HeapAlloc(GetProcessHeap(),0,sz + sizeof(L"\\*")); dllcache = malloc( sz + sizeof(L"\\*") );
RegQueryValueExW( hkey, L"SFCDllCacheDir", 0, NULL, (LPBYTE)dllcache, &sz); RegQueryValueExW( hkey, L"SFCDllCacheDir", 0, NULL, (LPBYTE)dllcache, &sz);
lstrcatW( dllcache, L"\\*" ); lstrcatW( dllcache, L"\\*" );
} }
...@@ -1230,7 +1229,7 @@ static int ProcessWindowsFileProtection(void) ...@@ -1230,7 +1229,7 @@ static int ProcessWindowsFileProtection(void)
if (!dllcache) if (!dllcache)
{ {
DWORD sz = GetSystemDirectoryW( NULL, 0 ); 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 ); GetSystemDirectoryW( dllcache, sz );
lstrcatW( dllcache, L"\\dllcache\\*" ); lstrcatW( dllcache, L"\\dllcache\\*" );
} }
...@@ -1276,7 +1275,7 @@ static int ProcessWindowsFileProtection(void) ...@@ -1276,7 +1275,7 @@ static int ProcessWindowsFileProtection(void)
find_rc = FindNextFileW(find_handle,&finddata); find_rc = FindNextFileW(find_handle,&finddata);
} }
FindClose(find_handle); FindClose(find_handle);
HeapFree(GetProcessHeap(),0,dllcache); free(dllcache);
return 1; return 1;
} }
...@@ -1327,10 +1326,10 @@ static INT_PTR CALLBACK wait_dlgproc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ...@@ -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_WAITICON, STM_SETICON, (WPARAM)icon, 0 );
SendDlgItemMessageW( hwnd, IDC_WAITTEXT, WM_GETTEXT, 1024, (LPARAM)text ); SendDlgItemMessageW( hwnd, IDC_WAITTEXT, WM_GETTEXT, 1024, (LPARAM)text );
len = lstrlenW(text) + lstrlenW(name) + 1; len = lstrlenW(text) + lstrlenW(name) + 1;
buffer = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); buffer = malloc( len * sizeof(WCHAR) );
swprintf( buffer, len, text, name ); swprintf( buffer, len, text, name );
SendDlgItemMessageW( hwnd, IDC_WAITTEXT, WM_SETTEXT, 0, (LPARAM)buffer ); SendDlgItemMessageW( hwnd, IDC_WAITTEXT, WM_SETTEXT, 0, (LPARAM)buffer );
HeapFree( GetProcessHeap(), 0, buffer ); free( buffer );
} }
break; break;
} }
...@@ -1362,7 +1361,7 @@ static HANDLE start_rundll32( const WCHAR *inf_path, const WCHAR *install, WORD ...@@ -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); 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 ); 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 )) 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 ...@@ -1370,7 +1369,7 @@ static HANDLE start_rundll32( const WCHAR *inf_path, const WCHAR *install, WORD
else else
pi.hProcess = 0; pi.hProcess = 0;
HeapFree( GetProcessHeap(), 0, buffer ); free( buffer );
return pi.hProcess; return pi.hProcess;
} }
...@@ -1525,7 +1524,7 @@ static void update_wineprefix( BOOL force ) ...@@ -1525,7 +1524,7 @@ static void update_wineprefix( BOOL force )
} }
done: 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 /* Process items in the StartUp group of the user's Programs under the Start Menu. Some installers put
......
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