As I discovered when using SDL and GCU clients on Windows, the "quit" hook is not called when closing the console (resulting in a lot of memory not being freed) because the CTRL_CLOSE_EVENT is not handled.
The code below fixes that problem nicely. Declare a control handler function in the main-xxx file:
And call it in the init_xxx function:
Et voila! Closing the Windows Console now calls hook_quit(), which should call cleanup_angband() and free allocated memory properly.
The code below fixes that problem nicely. Declare a control handler function in the main-xxx file:
Code:
static BOOL CtrlHandler(DWORD fdwCtrlType) { switch (fdwCtrlType) { case CTRL_CLOSE_EVENT: quit(NULL); return FALSE; default: return FALSE; } }
Code:
/* Activate hooks */ plog_aux = hook_plog; quit_aux = hook_quit; /* Register a control handler */ if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE)CtrlHandler, TRUE)) quit("Could not set control handler");