From 0998665463be273ee45ef9502f0feca8a7b01200 Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Tue, 14 Mar 2023 07:17:14 +0900 Subject: [PATCH] [MSPAINT] 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.cpp. - Call _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF) at the prologue of _tWinMain. This is a follow-up of #5151 (9abd9b6). CORE-18867 --- base/applications/mspaint/main.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/base/applications/mspaint/main.cpp b/base/applications/mspaint/main.cpp index 23c8f7a02b8..7d1f6af427b 100644 --- a/base/applications/mspaint/main.cpp +++ b/base/applications/mspaint/main.cpp @@ -6,10 +6,12 @@ * PROGRAMMERS: Benedikt Freisen */ -/* INCLUDES *********************************************************/ - #include "precomp.h" +#ifdef _DEBUG +#include +#endif + /* FUNCTIONS ********************************************************/ POINT start; @@ -159,6 +161,11 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff }; +#ifdef _DEBUG + /* Report any memory leaks on exit */ + _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); +#endif + /* init font for text tool */ ZeroMemory(&lfTextFont, sizeof(lfTextFont)); lfTextFont.lfHeight = 0;