https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9abd9b667a23afa916f9eedc7d0e65577a38c53f

commit 9abd9b667a23afa916f9eedc7d0e65577a38c53f
Author:     Katayama Hirofumi MZ <[email protected]>
AuthorDate: Tue Mar 14 07:08:56 2023 +0900
Commit:     GitHub <[email protected]>
CommitDate: Tue Mar 14 07:08:56 2023 +0900

    [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
---
 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 <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):

Reply via email to