[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 <crtdbg.h> at main.c.
- Call _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF) at the prologue of _tWinMain.
CORE-18837
This commit is contained in:
Katayama Hirofumi MZ
2023-03-14 07:08:56 +09:00
committed by GitHub
parent c766ee9ebb
commit 9abd9b667a

View File

@@ -27,6 +27,10 @@
#include <shlobj.h>
#include <strsafe.h>
#ifdef _DEBUG
#include <crtdbg.h>
#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):