From 5cf947edc771b0831bc9f007fcb5936bcebfce26 Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Tue, 14 Mar 2023 07:22:34 +0900 Subject: [PATCH] [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 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. --- base/applications/regedit/main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/base/applications/regedit/main.c b/base/applications/regedit/main.c index c762d6521dd..5ec8ddca2cc 100644 --- a/base/applications/regedit/main.c +++ b/base/applications/regedit/main.c @@ -20,6 +20,10 @@ #include "regedit.h" +#ifdef _DEBUG +#include +#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));