[Ttssh2-commit] [7558] _malloc_dbg(),_free_dbg()系の引数の誤りを修正

scmno****@osdn***** scmno****@osdn*****
2019年 4月 9日 (火) 02:11:37 JST


Revision: 7558
          https://osdn.net/projects/ttssh2/scm/svn/commits/7558
Author:   zmatsuo
Date:     2019-04-09 02:11:37 +0900 (Tue, 09 Apr 2019)
Log Message:
-----------
_malloc_dbg(),_free_dbg()系の引数の誤りを修正
_CRTDBG_MAP_ALLOC が defineされているプロジェクトで警告が出ないよう修正

Modified Paths:
--------------
    trunk/TTProxy/YCL/include/YCL/common.h
    trunk/teraterm/common/dlglib.c
    trunk/teraterm/common/dlglib_cpp.cpp
    trunk/teraterm/common/dlglib_tmpl.cpp
    trunk/teraterm/ttpmacro/ttmdlg.cpp

-------------- next part --------------
Modified: trunk/TTProxy/YCL/include/YCL/common.h
===================================================================
--- trunk/TTProxy/YCL/include/YCL/common.h	2019-04-08 17:11:23 UTC (rev 7557)
+++ trunk/TTProxy/YCL/include/YCL/common.h	2019-04-08 17:11:37 UTC (rev 7558)
@@ -16,6 +16,7 @@
 #include <windows.h>
 #include <malloc.h>
 #include <stdlib.h>
+#include <crtdbg.h>
 
 #ifndef countof
 #define countof(a) (sizeof (a) / sizeof (a)[0])
@@ -75,22 +76,11 @@
 #define YCLASSERT(condition, message) if (YclAssert(condition, message)) {__asm { int 3 }}
 #define YCLVERIFY(condition, message) if (YclAssert(condition, message)) {__asm { int 3 }}
 
-#ifdef __cplusplus
-extern "C" {
-#endif//__cplusplus
-void* _malloc_dbg(size_t length, const char* filename, int lineno);
-void* _realloc_dbg(void* pointer, size_t length, const char* filename, int lineno);
-void* _calloc_dbg(size_t num, size_t size, const char* filename, int lineno);
-void _free_dbg(void* pointer, const char* filename, int lineno);
-#ifdef __cplusplus
-}
-#endif//__cplusplus
+#define malloc(l)     _malloc_dbg((l), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define realloc(p, l) _realloc_dbg((p), (l), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define calloc(c, s)  _calloc_dbg((c), (s), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define free(p)       _free_dbg((p), _NORMAL_BLOCK)
 
-#define malloc(l)     _malloc_dbg((l), __FILE__, __LINE__)
-#define realloc(p, l) _realloc_dbg((p), (l), __FILE__, __LINE__)
-#define calloc(c, s)  _calloc_dbg((c), (s), __FILE__, __LINE__)
-#define free(p)       _free_dbg((p), __FILE__, __LINE__)
-
 //}
 #else
 //{

Modified: trunk/teraterm/common/dlglib.c
===================================================================
--- trunk/teraterm/common/dlglib.c	2019-04-08 17:11:23 UTC (rev 7557)
+++ trunk/teraterm/common/dlglib.c	2019-04-08 17:11:37 UTC (rev 7558)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 1994-1998 T. Teranishi
- * (C) 2008-2018 TeraTerm Project
+ * (C) 2008-2019 TeraTerm Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -36,8 +36,14 @@
 #include <stdio.h>
 #include <commctrl.h>
 #include <tchar.h>
+#include <crtdbg.h>
 #include "ttlib.h"	// for get_lang_font()
 
+#if defined(_DEBUG) && !defined(_CRTDBG_MAP_ALLOC)
+#define malloc(l) _malloc_dbg((l), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define free(p)   _free_dbg((p), _NORMAL_BLOCK)
+#endif
+
 void EnableDlgItem(HWND HDlg, int FirstId, int LastId)
 {
 	int i;

Modified: trunk/teraterm/common/dlglib_cpp.cpp
===================================================================
--- trunk/teraterm/common/dlglib_cpp.cpp	2019-04-08 17:11:23 UTC (rev 7557)
+++ trunk/teraterm/common/dlglib_cpp.cpp	2019-04-08 17:11:37 UTC (rev 7558)
@@ -1,5 +1,5 @@
 /*
- * (C) 2005-2018 TeraTerm Project
+ * (C) 2005-2019 TeraTerm Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -29,9 +29,16 @@
 /* Routines for dialog boxes */
 
 #include <windows.h>
+#include <crtdbg.h>
+
 #include "dlglib.h"
 #include "ttlib.h"
 
+#if defined(_DEBUG) && !defined(_CRTDBG_MAP_ALLOC)
+#define malloc(l) _malloc_dbg((l), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define free(p)   _free_dbg((p), _NORMAL_BLOCK)
+#endif
+
 // \x83_\x83C\x83A\x83\x8D\x83O\x83\x82\x81[\x83_\x83\x8B\x8F\xF3\x91Ԃ̎\x9E\x81AOnIdle()\x82\xF0\x8E\xC0\x8Ds\x82\xB7\x82\xE9
 //#define ENABLE_CALL_IDLE_MODAL	1
 

Modified: trunk/teraterm/common/dlglib_tmpl.cpp
===================================================================
--- trunk/teraterm/common/dlglib_tmpl.cpp	2019-04-08 17:11:23 UTC (rev 7557)
+++ trunk/teraterm/common/dlglib_tmpl.cpp	2019-04-08 17:11:37 UTC (rev 7558)
@@ -1,5 +1,5 @@
 /*
- * (C) 2005-2018 TeraTerm Project
+ * (C) 2005-2019 TeraTerm Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -34,9 +34,9 @@
 #include <assert.h>
 #include <crtdbg.h>
 
-#ifdef _DEBUG
+#if defined(_DEBUG) && !defined(_CRTDBG_MAP_ALLOC)
 #define malloc(l) _malloc_dbg((l), _NORMAL_BLOCK, __FILE__, __LINE__)
-#define free(p)   _free_dbg((p), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define free(p)   _free_dbg((p), _NORMAL_BLOCK)
 #endif
 
 //#define	_countof(ary)	(sizeof(ary)/sizeof(ary[0]))

Modified: trunk/teraterm/ttpmacro/ttmdlg.cpp
===================================================================
--- trunk/teraterm/ttpmacro/ttmdlg.cpp	2019-04-08 17:11:23 UTC (rev 7557)
+++ trunk/teraterm/ttpmacro/ttmdlg.cpp	2019-04-08 17:11:37 UTC (rev 7558)
@@ -54,7 +54,7 @@
 #define malloc(l)     _malloc_dbg((l), _NORMAL_BLOCK, __FILE__, __LINE__)
 #define realloc(p, l) _realloc_dbg((p), (l), _NORMAL_BLOCK, __FILE__, __LINE__)
 #define calloc(c, s)  _calloc_dbg((c), (s), _NORMAL_BLOCK, __FILE__, __LINE__)
-#define free(p)       _free_dbg((p), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define free(p)       _free_dbg((p), _NORMAL_BLOCK)
 #define strdup(s)	  _strdup_dbg((s), _NORMAL_BLOCK, __FILE__, __LINE__)
 #define _strdup(s)	  _strdup_dbg((s), _NORMAL_BLOCK, __FILE__, __LINE__)
 #endif


Ttssh2-commit メーリングリストの案内