Windows NetHackW memory leak bit
This commit is contained in:
@@ -252,6 +252,8 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern void free_menu_data(void);
|
||||
|
||||
void
|
||||
free_winmain_stuff(void)
|
||||
{
|
||||
@@ -271,6 +273,7 @@ free_winmain_stuff(void)
|
||||
windowdata[cnt].address = 0;
|
||||
}
|
||||
}
|
||||
free_menu_data();
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
@@ -27,7 +27,7 @@ static TCHAR szMainWindowClass[] = TEXT("MSNHMainWndClass");
|
||||
static TCHAR szTitle[MAX_LOADSTRING];
|
||||
struct window_tracking_data windowdata[MAXWINDOWS];
|
||||
extern void mswin_display_splash_window(BOOL);
|
||||
|
||||
extern void free_menu_data(void); /* mhmenu.c */
|
||||
LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
|
||||
static LRESULT onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
@@ -95,6 +95,8 @@ static void SelectMenuItem(HWND hwndList, PNHMenuWindow data, int item,
|
||||
int count);
|
||||
static void reset_menu_count(HWND hwndList, PNHMenuWindow data);
|
||||
static BOOL onListChar(HWND hWnd, HWND hwndList, WORD ch);
|
||||
static genericptr_t menu_data_to_free;
|
||||
void free_menu_data(void);
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
HWND
|
||||
@@ -627,6 +629,8 @@ onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
data->menui.menu.items, data->menui.menu.allocated * sizeof(NHMenuItem));
|
||||
if (!data->menui.menu.items)
|
||||
free(was);
|
||||
else
|
||||
menu_data_to_free = (genericptr_t) data->menui.menu.items;
|
||||
}
|
||||
|
||||
if (data->menui.menu.items) {
|
||||
@@ -719,6 +723,14 @@ onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
free_menu_data(void)
|
||||
{
|
||||
if (menu_data_to_free != 0)
|
||||
free(menu_data_to_free), menu_data_to_free = 0;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
void
|
||||
LayoutMenu(HWND hWnd)
|
||||
|
||||
Reference in New Issue
Block a user