From 9abd9b667a23afa916f9eedc7d0e65577a38c53f Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Tue, 14 Mar 2023 07:08:56 +0900 Subject: [PATCH] [NOTEPAD] Use _CrtSetDbgFlag to check memory leak (#5151) We can borrow the power of CRT debug. These changes are effective for debug version only: - Insert #include at main.c. - Call _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF) at the prologue of _tWinMain. CORE-18837 --- base/applications/notepad/main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/base/applications/notepad/main.c b/base/applications/notepad/main.c index 6c3ec3d6d19..f9e437f7720 100644 --- a/base/applications/notepad/main.c +++ b/base/applications/notepad/main.c @@ -27,6 +27,10 @@ #include #include +#ifdef _DEBUG +#include +#endif + NOTEPAD_GLOBALS Globals; static ATOM aFINDMSGSTRING; @@ -565,10 +569,14 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE prev, LPTSTR cmdline, int sh MONITORINFO info; INT x, y; RECT rcIntersect; - static const TCHAR className[] = _T("Notepad"); static const TCHAR winName[] = _T("Notepad"); +#ifdef _DEBUG + /* Report any memory leaks on exit */ + _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); +#endif + switch (GetUserDefaultUILanguage()) { case MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT):