Add hack to compensate for memdebug premature scan

This commit is contained in:
Kp 2016-12-08 03:32:06 +00:00
parent 515476f02b
commit 6e03e6b4c1

View file

@ -502,6 +502,26 @@ static int main(int argc, char *argv[])
show_titles();
set_screen_mode(SCREEN_MENU);
#ifdef DEBUG_MEMORY_ALLOCATIONS
/* Memdebug runs before global destructors, so it incorrectly
* reports as leaked any allocations that would be freed by a global
* destructor. This local will force the newmenu globals to be
* reset before memdebug scans, which prevents memdebug falsely
* reporting them as leaked.
*
* External tools, such as Valgrind, know to run global destructors
* before checking for leaks, so this hack is only necessary when
* memdebug is used.
*/
struct hack_free_global_backgrounds
{
~hack_free_global_backgrounds()
{
newmenu_free_background();
}
};
hack_free_global_backgrounds hack_free_global_background;
#endif
con_printf( CON_DEBUG, "\nDoing gamedata_init..." );
gamedata_init();