AmendHub

Download:

jcs

/

subtext

/

amendments

/

588

main: When MALLOC_DEBUG is defined, add a Debug menu to dump allocs


jcs made amendment 588 2 months ago
--- main.c Mon Feb 12 23:12:08 2024 +++ main.c Thu Feb 15 15:31:32 2024 @@ -41,6 +41,11 @@ unsigned long blanker_last_blank = 0; WindowPtr blanker_win = NULL; struct uthread *periodic_job_thread = NULL; +#ifdef MALLOC_DEBUG +MenuHandle debug_menu; +#define DEBUG_MENU_DUMP_ID 999 +#endif + bool handle_menu(long menu_id); void handle_exit(void); void blanker_idle(void); @@ -82,6 +87,11 @@ main(void) AddResMenu(apple_menu, 'DRVR'); if (!(file_menu = GetMHandle(FILE_MENU_ID))) panic("no file menu"); +#ifdef MALLOC_DEBUG + debug_menu = NewMenu(DEBUG_MENU_DUMP_ID, "\pDebug"); + AppendMenu(debug_menu, "\pDump Allocations"); + InsertMenu(debug_menu, 0); +#endif DrawMenuBar(); /* see if we were started by double-clicking a .bbs file */ @@ -358,6 +368,16 @@ handle_menu(long menu_id) } ret = true; break; +#ifdef MALLOC_DEBUG + case DEBUG_MENU_DUMP_ID: + switch (LoWord(menu_id)) { + case 1: + xalloc_print(logger_printf); + break; + } + ret = true; + break; +#endif } HiliteMenu(0);