[REGEDIT] Use _CrtSetDbgFlag to check memory leak

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 wWinMain.

This is a follow-up of #5151 (9abd9b6) and 0998665.
This commit is contained in:
Katayama Hirofumi MZ 2023-03-14 07:22:34 +09:00
parent 0998665463
commit 5cf947edc7

View file

@ -20,6 +20,10 @@
#include "regedit.h"
#ifdef _DEBUG
#include <crtdbg.h>
#endif
BOOL ProcessCmdLine(WCHAR *cmdline);
const WCHAR *reg_class_namesW[] = {L"HKEY_LOCAL_MACHINE", L"HKEY_USERS",
@ -205,6 +209,11 @@ int WINAPI wWinMain(HINSTANCE hInstance,
UNREFERENCED_PARAMETER(hPrevInstance);
#ifdef _DEBUG
/* Report any memory leaks on exit */
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif
/* Initialize global strings */
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, ARRAY_SIZE(szTitle));
LoadStringW(hInstance, IDC_REGEDIT_FRAME, szFrameClass, ARRAY_SIZE(szFrameClass));