free up some console alloc()'d memory under curses

tty takes care of this, but it wasn't being done under curses
This commit is contained in:
nhmall
2026-05-14 23:57:25 -04:00
parent 5edb093e14
commit accb14b797
3 changed files with 19 additions and 7 deletions
+1 -1
View File
@@ -2182,7 +2182,7 @@ extern void synch_cursor(void);
extern void nethack_enter_consoletty(void); extern void nethack_enter_consoletty(void);
extern int get_console_width(void); extern int get_console_width(void);
extern int get_console_height(void); extern int get_console_height(void);
extern void consoletty_exit(void); extern void console_exit(void);
extern int set_keyhandling_via_option(void); extern int set_keyhandling_via_option(void);
#ifdef ENHANCED_SYMBOLS #ifdef ENHANCED_SYMBOLS
extern void tty_utf8graphics_fixup(void); extern void tty_utf8graphics_fixup(void);
+11 -6
View File
@@ -954,7 +954,7 @@ tty_number_pad(int state UNUSED)
void void
term_shutdown(void) term_shutdown(void)
{ {
consoletty_exit(); console_exit();
} }
#ifdef ASCIIGRAPH #ifdef ASCIIGRAPH
@@ -1044,14 +1044,19 @@ consoletty_open(int mode UNUSED)
extern void set_emergency_io(void); extern void set_emergency_io(void);
void void
consoletty_exit(void) console_exit(void)
{ {
free_custom_colors(); free_custom_colors();
free((genericptr_t) console.front_buffer); if (console.front_buffer)
free((genericptr_t) console.back_buffer); free((genericptr_t) console.front_buffer);
if (console.back_buffer)
free((genericptr_t) console.back_buffer);
console.front_buffer = console.back_buffer = 0; console.front_buffer = console.back_buffer = 0;
free((genericptr_t) console.localestr); if (console.localestr)
free((genericptr_t) console.orig_localestr); free((genericptr_t) console.localestr), console.localestr = 0;
if (console.orig_localestr)
free((genericptr_t) console.orig_localestr),
console.orig_localestr = 0;
set_emergency_io(); set_emergency_io();
} }
+7
View File
@@ -526,6 +526,13 @@ nethack_exit(int code)
genl_status_finish(); genl_status_finish();
#ifdef MSWIN_GRAPHICS #ifdef MSWIN_GRAPHICS
free_winmain_stuff(); free_winmain_stuff();
#endif
#ifdef WIN32CON
#ifdef CURSES_GRAPHICS
if (WINDOWPORT(curses)) {
console_exit();
}
#endif
#endif #endif
exit(code); exit(code);
} }