In Visual Studio when including crtdbg.h file with both _DEBUG and _CRTDBG_MAP_ALLOC macros set, all standard memory allocation functions are redefined and forwarded to their *_dbg siblings. This allows to track memory allocation in program compiled and linked with debug version of CRT DLL library.
Add same support also into mingw-w64. This allows to use memory leak functionality provided by msvcrtd.dll when compiling with gcc's -mcrtdll=msvcrtd and -D_DEBUG and -D_CRTDBG_MAP_ALLOC switches. Note that those redefined functions needs macro guards in other header files to prevent expadning redefined macros when declaring non-debug functions. For example when declaring void *__cdecl malloc(size_t _Size); in malloc.h header file, it needs to be ensured that malloc macro from crtdbg.h #define malloc(s) _malloc_dbg(s,_NORMAL_BLOCK,__FILE__,__LINE__) does not expad for standard malloc declaration. Same guard technique via pragma push_macro, undef and pragma pop_macro is used by Visual Studio. --- mingw-w64-headers/crt/corecrt_wstdlib.h | 10 +++- mingw-w64-headers/crt/crtdbg.h | 44 ++++++++++++++++ mingw-w64-headers/crt/direct.h | 33 ++++++++++++ mingw-w64-headers/crt/io.h | 15 ++++++ mingw-w64-headers/crt/malloc.h | 67 ++++++++++++++++++++++++ mingw-w64-headers/crt/mbstring.h | 7 +++ mingw-w64-headers/crt/sec_api/stdlib_s.h | 10 +++- mingw-w64-headers/crt/stdio.h | 21 ++++++++ mingw-w64-headers/crt/stdlib.h | 63 ++++++++++++++++++++++ mingw-w64-headers/crt/string.h | 28 ++++++++++ mingw-w64-headers/crt/wchar.h | 42 +++++++++++++++ 11 files changed, 338 insertions(+), 2 deletions(-) diff --git a/mingw-w64-headers/crt/corecrt_wstdlib.h b/mingw-w64-headers/crt/corecrt_wstdlib.h index 6169c2d40ac5..d525397e0970 100644 --- a/mingw-w64-headers/crt/corecrt_wstdlib.h +++ b/mingw-w64-headers/crt/corecrt_wstdlib.h @@ -10,6 +10,15 @@ #ifdef __cplusplus extern "C" { +#endif + +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("_wdupenv_s") +#undef _wdupenv_s +#endif + _CRTIMP errno_t __cdecl _wdupenv_s(wchar_t **_Buffer,size_t *_BufferSizeInWords,const wchar_t *_VarName); +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("_wdupenv_s") #endif _CRTIMP errno_t __cdecl _itow_s (int _Val,wchar_t *_DstBuf,size_t _SizeInWords,int _Radix); @@ -24,7 +33,6 @@ extern "C" { _CRTIMP errno_t __cdecl _wgetenv_s(size_t *_ReturnSize,wchar_t *_DstBuf,size_t _DstSizeInWords,const wchar_t *_VarName); __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_1(errno_t,_wgetenv_s,size_t*,_ReturnSize,wchar_t,_DstBuf,const wchar_t*,_VarName) - _CRTIMP errno_t __cdecl _wdupenv_s(wchar_t **_Buffer,size_t *_BufferSizeInWords,const wchar_t *_VarName); _CRTIMP errno_t __cdecl _i64tow_s(__int64 _Val,wchar_t *_DstBuf,size_t _SizeInWords,int _Radix); _CRTIMP errno_t __cdecl _ui64tow_s(unsigned __int64 _Val,wchar_t *_DstBuf,size_t _SizeInWords,int _Radix); diff --git a/mingw-w64-headers/crt/crtdbg.h b/mingw-w64-headers/crt/crtdbg.h index 4c63d5580a3c..c498bcfa63f0 100644 --- a/mingw-w64-headers/crt/crtdbg.h +++ b/mingw-w64-headers/crt/crtdbg.h @@ -331,6 +331,50 @@ _CRTIMP int __cdecl _CrtDbgReportW(int _ReportType, const wchar_t * _Filename, i #define _CrtDbgBreak() __debugbreak() +#ifdef _CRTDBG_MAP_ALLOC + +#define malloc(s) _malloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__) +#define calloc(c, s) _calloc_dbg(c, s, _NORMAL_BLOCK, __FILE__, __LINE__) +#define realloc(p, s) _realloc_dbg(p, s, _NORMAL_BLOCK, __FILE__, __LINE__) +#define _recalloc(p, c, s) _recalloc_dbg(p, c, s, _NORMAL_BLOCK, __FILE__, __LINE__) +#define _expand(p, s) _expand_dbg(p, s, _NORMAL_BLOCK, __FILE__, __LINE__) +#define free(p) _free_dbg(p, _NORMAL_BLOCK) +#define _msize(p) _msize_dbg(p, _NORMAL_BLOCK) +#define _aligned_msize(p, a, o) _aligned_msize_dbg(p, a, o) +#define _aligned_malloc(s, a) _aligned_malloc_dbg(s, a, __FILE__, __LINE__) +#define _aligned_realloc(p, s, a) _aligned_realloc_dbg(p, s, a, __FILE__, __LINE__) +#define _aligned_recalloc(p, c, s, a) _aligned_recalloc_dbg(p, c, s, a, __FILE__, __LINE__) +#define _aligned_offset_malloc(s, a, o) _aligned_offset_malloc_dbg(s, a, o, __FILE__, __LINE__) +#define _aligned_offset_realloc(p, s, a, o) _aligned_offset_realloc_dbg(p, s, a, o, __FILE__, __LINE__) +#define _aligned_offset_recalloc(p, c, s, a, o) _aligned_offset_recalloc_dbg(p, c, s, a, o, __FILE__, __LINE__) +#define _aligned_free(p) _aligned_free_dbg(p) + +#define _malloca(s) _malloca_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__) +#define _freea(p) _freea_dbg(p, _NORMAL_BLOCK) + +#define _strdup(s) _strdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__) +#define _wcsdup(s) _wcsdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__) +#define _mbsdup(s) _strdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__) +#define _tempnam(s1, s2) _tempnam_dbg(s1, s2, _NORMAL_BLOCK, __FILE__, __LINE__) +#define _wtempnam(s1, s2) _wtempnam_dbg(s1, s2, _NORMAL_BLOCK, __FILE__, __LINE__) +#define _fullpath(s1, s2, le) _fullpath_dbg(s1, s2, le, _NORMAL_BLOCK, __FILE__, __LINE__) +#define _wfullpath(s1, s2, le) _wfullpath_dbg(s1, s2, le, _NORMAL_BLOCK, __FILE__, __LINE__) +#define _getcwd(s, le) _getcwd_dbg(s, le, _NORMAL_BLOCK, __FILE__, __LINE__) +#define _wgetcwd(s, le) _wgetcwd_dbg(s, le, _NORMAL_BLOCK, __FILE__, __LINE__) +#define _getdcwd(d, s, le) _getdcwd_dbg(d, s, le, _NORMAL_BLOCK, __FILE__, __LINE__) +#define _wgetdcwd(d, s, le) _wgetdcwd_dbg(d, s, le, _NORMAL_BLOCK, __FILE__, __LINE__) +#define _getdcwd_nolock(d, s, le) _getdcwd_lk_dbg(d, s, le, _NORMAL_BLOCK, __FILE__, __LINE__) +#define _wgetdcwd_nolock(d, s, le) _wgetdcwd_lk_dbg(d, s, le, _NORMAL_BLOCK, __FILE__, __LINE__) +#define _dupenv_s(ps1, size, s2) _dupenv_s_dbg(ps1, size, s2, _NORMAL_BLOCK, __FILE__, __LINE__) +#define _wdupenv_s(ps1, size, s2) _wdupenv_s_dbg(ps1, size, s2, _NORMAL_BLOCK, __FILE__, __LINE__) + +#define strdup(s) _strdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__) +#define wcsdup(s) _wcsdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__) +#define tempnam(s1, s2) _tempnam_dbg(s1, s2, _NORMAL_BLOCK, __FILE__, __LINE__) +#define getcwd(s, le) _getcwd_dbg(s, le, _NORMAL_BLOCK, __FILE__, __LINE__) + +#endif /* _CRTDBG_MAP_ALLOC */ + _CRTIMP long * __cdecl __p__crtBreakAlloc(void); #define _crtBreakAlloc (*__p__crtBreakAlloc()) diff --git a/mingw-w64-headers/crt/direct.h b/mingw-w64-headers/crt/direct.h index e6d95f271025..df53e95f2d72 100644 --- a/mingw-w64-headers/crt/direct.h +++ b/mingw-w64-headers/crt/direct.h @@ -25,10 +25,23 @@ extern "C" { }; #endif +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("_getcwd") +#undef _getcwd +#pragma push_macro("_getdcwd") +#undef _getdcwd +#pragma push_macro("_getdcwd_nolock") +#undef _getdcwd_nolock +#endif _CRTIMP char *__cdecl _getcwd(char *_DstBuf,int _SizeInBytes); _CRTIMP char *__cdecl _getdcwd(int _Drive,char *_DstBuf,int _SizeInBytes); #if __MSVCRT_VERSION__ >= 0x800 char *__cdecl _getdcwd_nolock(int _Drive,char *_DstBuf,int _SizeInBytes); +#endif +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("_getcwd") +#pragma pop_macro("_getdcwd") +#pragma pop_macro("_getdcwd_nolock") #endif _CRTIMP int __cdecl _chdir(const char *_Path); _CRTIMP int __cdecl _mkdir(const char *_Path); @@ -46,10 +59,23 @@ extern "C" { #ifndef _WDIRECT_DEFINED #define _WDIRECT_DEFINED +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("_wgetcwd") +#undef _wgetcwd +#pragma push_macro("_wgetdcwd") +#undef _wgetdcwd +#pragma push_macro("_wgetdcwd_nolock") +#undef _wgetdcwd_nolock +#endif _CRTIMP wchar_t *__cdecl _wgetcwd(wchar_t *_DstBuf,int _SizeInWords); _CRTIMP wchar_t *__cdecl _wgetdcwd(int _Drive,wchar_t *_DstBuf,int _SizeInWords); #if __MSVCRT_VERSION__ >= 0x800 wchar_t *__cdecl _wgetdcwd_nolock(int _Drive,wchar_t *_DstBuf,int _SizeInWords); +#endif +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("_wgetcwd") +#pragma pop_macro("_wgetdcwd") +#pragma pop_macro("_wgetdcwd_nolock") #endif _CRTIMP int __cdecl _wchdir(const wchar_t *_Path); _CRTIMP int __cdecl _wmkdir(const wchar_t *_Path); @@ -60,7 +86,14 @@ extern "C" { #define diskfree_t _diskfree_t +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("getcwd") +#undef getcwd +#endif char *__cdecl getcwd(char *_DstBuf,int _SizeInBytes) __MINGW_ATTRIB_DEPRECATED_MSVC2005; +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("getcwd") +#endif int __cdecl chdir(const char *_Path) __MINGW_ATTRIB_DEPRECATED_MSVC2005; int __cdecl mkdir(const char *_Path) __MINGW_ATTRIB_DEPRECATED_MSVC2005; int __cdecl rmdir(const char *_Path) __MINGW_ATTRIB_DEPRECATED_MSVC2005; diff --git a/mingw-w64-headers/crt/io.h b/mingw-w64-headers/crt/io.h index 4994191a967d..a6dc2f8a1bb2 100644 --- a/mingw-w64-headers/crt/io.h +++ b/mingw-w64-headers/crt/io.h @@ -24,7 +24,15 @@ extern "C" { #endif +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("_getcwd") +#undef _getcwd +#endif _CRTIMP char* __cdecl _getcwd (char*, int); +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("_getcwd") +#endif + #ifndef _FSIZE_T_DEFINED typedef unsigned long _fsize_t; #define _FSIZE_T_DEFINED @@ -278,7 +286,14 @@ _CRTIMP char* __cdecl _getcwd (char*, int); #ifndef NO_OLDNAMES #ifndef _UWIN int __cdecl chdir (const char *) __MINGW_ATTRIB_DEPRECATED_MSVC2005; +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("getcwd") +#undef getcwd +#endif char *__cdecl getcwd (char *, int) __MINGW_ATTRIB_DEPRECATED_MSVC2005; +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("getcwd") +#endif int __cdecl mkdir (const char *) __MINGW_ATTRIB_DEPRECATED_MSVC2005; char *__cdecl mktemp(char *) __MINGW_ATTRIB_DEPRECATED_MSVC2005; int __cdecl rmdir (const char*) __MINGW_ATTRIB_DEPRECATED_MSVC2005; diff --git a/mingw-w64-headers/crt/malloc.h b/mingw-w64-headers/crt/malloc.h index d02f3ee7bf5c..9c498c2918bd 100644 --- a/mingw-w64-headers/crt/malloc.h +++ b/mingw-w64-headers/crt/malloc.h @@ -61,6 +61,36 @@ extern "C" { #ifndef _CRT_ALLOCATION_DEFINED #define _CRT_ALLOCATION_DEFINED + +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("calloc") +#undef calloc +#pragma push_macro("free") +#undef free +#pragma push_macro("malloc") +#undef malloc +#pragma push_macro("realloc") +#undef realloc +#pragma push_macro("_aligned_free") +#undef _aligned_free +#pragma push_macro("_aligned_malloc") +#undef _aligned_malloc +#pragma push_macro("_aligned_offset_malloc") +#undef _aligned_offset_malloc +#pragma push_macro("_aligned_realloc") +#undef _aligned_realloc +#pragma push_macro("_aligned_offset_realloc") +#undef _aligned_offset_realloc +#pragma push_macro("_recalloc") +#undef _recalloc +#pragma push_macro("_aligned_recalloc") +#undef _aligned_recalloc +#pragma push_macro("_aligned_offset_recalloc") +#undef _aligned_offset_recalloc +#pragma push_macro("_aligned_msize") +#undef _aligned_msize +#endif + void *__cdecl calloc(size_t _NumOfElements,size_t _SizeOfElements); void __cdecl free(void *_Memory); void *__cdecl malloc(size_t _Size); @@ -78,6 +108,23 @@ extern "C" { _CRTIMP void *__cdecl _aligned_offset_recalloc(void *_Memory,size_t _Count,size_t _Size,size_t _Alignment,size_t _Offset); _CRTIMP size_t __cdecl _aligned_msize(void *_Memory,size_t _Alignment,size_t _Offset); # endif + +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("calloc") +#pragma pop_macro("free") +#pragma pop_macro("malloc") +#pragma pop_macro("realloc") +#pragma pop_macro("_aligned_free") +#pragma pop_macro("_aligned_malloc") +#pragma pop_macro("_aligned_offset_malloc") +#pragma pop_macro("_aligned_realloc") +#pragma pop_macro("_aligned_offset_realloc") +#pragma pop_macro("_recalloc") +#pragma pop_macro("_aligned_recalloc") +#pragma pop_macro("_aligned_offset_recalloc") +#pragma pop_macro("_aligned_msize") +#endif + #endif /* Users should really use MS provided versions */ @@ -98,8 +145,19 @@ void * __mingw_aligned_realloc (void *_Memory, size_t _Size, size_t _Offset); #endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */ _CRTIMP unsigned long __cdecl _set_malloc_crt_max_wait(unsigned long _NewValue); +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("_expand") +#undef _expand +#pragma push_macro("_msize") +#undef _msize +#endif _CRTIMP void *__cdecl _expand(void *_Memory,size_t _NewSize); _CRTIMP size_t __cdecl _msize(void *_Memory); +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("_expand") +#pragma pop_macro("_msize") +#endif + #ifdef __GNUC__ #undef _alloca #define _alloca(x) __builtin_alloca((x)) @@ -138,11 +196,20 @@ void * __mingw_aligned_realloc (void *_Memory, size_t _Size, size_t _Offset); } #endif +#ifdef _DEBUG +#ifndef _CRTDBG_MAP_ALLOC +#undef _malloca +#define _malloca(size) \ + _MarkAllocaS(malloc((size) + _ALLOCA_S_MARKER_SIZE), _ALLOCA_S_HEAP_MARKER) +#endif +#else #undef _malloca #define _malloca(size) \ ((((size) + _ALLOCA_S_MARKER_SIZE) <= _ALLOCA_S_THRESHOLD) ? \ _MarkAllocaS(_alloca((size) + _ALLOCA_S_MARKER_SIZE),_ALLOCA_S_STACK_MARKER) : \ _MarkAllocaS(malloc((size) + _ALLOCA_S_MARKER_SIZE),_ALLOCA_S_HEAP_MARKER)) +#endif + #undef _FREEA_INLINE #define _FREEA_INLINE diff --git a/mingw-w64-headers/crt/mbstring.h b/mingw-w64-headers/crt/mbstring.h index b6e48a883992..e9e43a13a1e1 100644 --- a/mingw-w64-headers/crt/mbstring.h +++ b/mingw-w64-headers/crt/mbstring.h @@ -31,7 +31,14 @@ extern "C" { #ifndef _MBSTRING_DEFINED #define _MBSTRING_DEFINED +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("_mbsdup") +#undef _mbsdup +#endif _CRTIMP unsigned char *__cdecl _mbsdup(const unsigned char *_Str); +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("_mbsdup") +#endif _CRTIMP unsigned int __cdecl _mbbtombc(unsigned int _Ch); _CRTIMP unsigned int __cdecl _mbbtombc_l(unsigned int _Ch,_locale_t _Locale); _CRTIMP int __cdecl _mbbtype(unsigned char _Ch,int _CType); diff --git a/mingw-w64-headers/crt/sec_api/stdlib_s.h b/mingw-w64-headers/crt/sec_api/stdlib_s.h index f7d76fecb165..32f4767e4d49 100644 --- a/mingw-w64-headers/crt/sec_api/stdlib_s.h +++ b/mingw-w64-headers/crt/sec_api/stdlib_s.h @@ -12,8 +12,16 @@ extern "C" { #endif - _CRTIMP void * __cdecl bsearch_s(const void *_Key,const void *_Base,rsize_t _NumOfElements,rsize_t _SizeOfElements,int (__cdecl * _PtFuncCompare)(void *, const void *, const void *), void *_Context); +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("_dupenv_s") +#undef _dupenv_s +#endif _CRTIMP errno_t __cdecl _dupenv_s(char **_PBuffer,size_t *_PBufferSizeInBytes,const char *_VarName); +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("_dupenv_s") +#endif + + _CRTIMP void * __cdecl bsearch_s(const void *_Key,const void *_Base,rsize_t _NumOfElements,rsize_t _SizeOfElements,int (__cdecl * _PtFuncCompare)(void *, const void *, const void *), void *_Context); _CRTIMP errno_t __cdecl getenv_s(size_t *_ReturnSize,char *_DstBuf,rsize_t _DstSize,const char *_VarName); __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_1(errno_t, getenv_s, size_t *, _ReturnSize, char, _Dest, const char *, _VarName) _CRTIMP errno_t __cdecl _itoa_s(int _Value,char *_DstBuf,size_t _Size,int _Radix); diff --git a/mingw-w64-headers/crt/stdio.h b/mingw-w64-headers/crt/stdio.h index d6227f689868..7e0d3d9175f0 100644 --- a/mingw-w64-headers/crt/stdio.h +++ b/mingw-w64-headers/crt/stdio.h @@ -540,8 +540,15 @@ int vsnprintf (char *__stream, size_t __n, const char *__format, __builtin_va_li _CRTIMP int __cdecl _fileno(FILE *_File); #ifdef _POSIX_ int __cdecl fileno(FILE *_File) __MINGW_ATTRIB_DEPRECATED_MSVC2005; +#endif +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("_tempnam") +#undef _tempnam #endif _CRTIMP char *__cdecl _tempnam(const char *_DirName,const char *_FilePrefix); +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("_tempnam") +#endif _CRTIMP int __cdecl _flushall(void); FILE *__cdecl fopen(const char * __restrict__ _Filename,const char * __restrict__ _Mode) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; FILE *fopen64(const char * __restrict__ filename,const char * __restrict__ mode); @@ -1309,7 +1316,14 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, __builti #endif #endif +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("_wtempnam") +#undef _wtempnam +#endif _CRTIMP wchar_t *__cdecl _wtempnam(const wchar_t *_Directory,const wchar_t *_FilePrefix); +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("_wtempnam") +#endif _CRTIMP int __cdecl _snwscanf(const wchar_t * __restrict__ _Src,size_t _MaxCount,const wchar_t * __restrict__ _Format,...); _CRTIMP FILE *__cdecl _wfdopen(int _FileHandle ,const wchar_t *_Mode); _CRTIMP FILE *__cdecl _wfopen(const wchar_t * __restrict__ _Filename,const wchar_t *__restrict__ _Mode) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; @@ -1387,7 +1401,14 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const wchar_t *__format, __builti #define P_tmpdir _P_tmpdir #define SYS_OPEN _SYS_OPEN +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("tempnam") +#undef tempnam +#endif char *__cdecl tempnam(const char *_Directory,const char *_FilePrefix) __MINGW_ATTRIB_DEPRECATED_MSVC2005; +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("tempnam") +#endif int __cdecl fcloseall(void) __MINGW_ATTRIB_DEPRECATED_MSVC2005; FILE *__cdecl fdopen(int _FileHandle,const char *_Format) __MINGW_ATTRIB_DEPRECATED_MSVC2005; int __cdecl fgetchar(void) __MINGW_ATTRIB_DEPRECATED_MSVC2005; diff --git a/mingw-w64-headers/crt/stdlib.h b/mingw-w64-headers/crt/stdlib.h index dabeb3cdb61a..d43fa33b7f2c 100644 --- a/mingw-w64-headers/crt/stdlib.h +++ b/mingw-w64-headers/crt/stdlib.h @@ -419,6 +419,36 @@ float __cdecl __MINGW_NOTHROW strtof(const char * __restrict__ _Str,char ** __re #ifndef _CRT_ALLOCATION_DEFINED #define _CRT_ALLOCATION_DEFINED + +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("calloc") +#undef calloc +#pragma push_macro("free") +#undef free +#pragma push_macro("malloc") +#undef malloc +#pragma push_macro("realloc") +#undef realloc +#pragma push_macro("_aligned_free") +#undef _aligned_free +#pragma push_macro("_aligned_malloc") +#undef _aligned_malloc +#pragma push_macro("_aligned_offset_malloc") +#undef _aligned_offset_malloc +#pragma push_macro("_aligned_realloc") +#undef _aligned_realloc +#pragma push_macro("_aligned_offset_realloc") +#undef _aligned_offset_realloc +#pragma push_macro("_recalloc") +#undef _recalloc +#pragma push_macro("_aligned_recalloc") +#undef _aligned_recalloc +#pragma push_macro("_aligned_offset_recalloc") +#undef _aligned_offset_recalloc +#pragma push_macro("_aligned_msize") +#undef _aligned_msize +#endif + void *__cdecl calloc(size_t _NumOfElements,size_t _SizeOfElements); void __cdecl free(void *_Memory); void *__cdecl malloc(size_t _Size); @@ -434,6 +464,23 @@ float __cdecl __MINGW_NOTHROW strtof(const char * __restrict__ _Str,char ** __re _CRTIMP void *__cdecl _aligned_offset_recalloc(void *_Memory,size_t _Count,size_t _Size,size_t _Alignment,size_t _Offset); _CRTIMP size_t __cdecl _aligned_msize(void *_Memory,size_t _Alignment,size_t _Offset); # endif + +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("calloc") +#pragma pop_macro("free") +#pragma pop_macro("malloc") +#pragma pop_macro("realloc") +#pragma pop_macro("_aligned_free") +#pragma pop_macro("_aligned_malloc") +#pragma pop_macro("_aligned_offset_malloc") +#pragma pop_macro("_aligned_realloc") +#pragma pop_macro("_aligned_offset_realloc") +#pragma pop_macro("_recalloc") +#pragma pop_macro("_aligned_recalloc") +#pragma pop_macro("_aligned_offset_recalloc") +#pragma pop_macro("_aligned_msize") +#endif + #endif #ifndef _WSTDLIB_DEFINED @@ -497,7 +544,16 @@ float __cdecl __MINGW_NOTHROW strtof(const char * __restrict__ _Str,char ** __re #ifndef _POSIX_ #define _CVTBUFSIZE (309+40) + +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("_fullpath") +#undef _fullpath +#endif _CRTIMP char *__cdecl _fullpath(char *_FullPath,const char *_Path,size_t _SizeInBytes); +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("_fullpath") +#endif + _CRTIMP char *__cdecl _ecvt(double _Val,int _NumOfDigits,int *_PtDec,int *_PtSign) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; _CRTIMP char *__cdecl _fcvt(double _Val,int _NumOfDec,int *_PtDec,int *_PtSign) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; _CRTIMP char *__cdecl _gcvt(double _Val,int _NumOfDigits,char *_DstBuf) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; @@ -559,7 +615,14 @@ unsigned long __cdecl _lrotr(unsigned long,int); #ifndef _WSTDLIBP_DEFINED #define _WSTDLIBP_DEFINED +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("_wfullpath") +#undef _wfullpath +#endif _CRTIMP wchar_t *__cdecl _wfullpath(wchar_t *_FullPath,const wchar_t *_Path,size_t _SizeInWords); +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("_wfullpath") +#endif _CRTIMP void __cdecl _wmakepath(wchar_t *_ResultPath,const wchar_t *_Drive,const wchar_t *_Dir,const wchar_t *_Filename,const wchar_t *_Ext); #ifndef _CRT_WPERROR_DEFINED #define _CRT_WPERROR_DEFINED diff --git a/mingw-w64-headers/crt/string.h b/mingw-w64-headers/crt/string.h index 813cd5bec593..1832e38ed85a 100644 --- a/mingw-w64-headers/crt/string.h +++ b/mingw-w64-headers/crt/string.h @@ -64,7 +64,14 @@ extern "C" { size_t __cdecl strlen(const char *_Str); size_t __cdecl strnlen(const char *_Str,size_t _MaxCount); void *__cdecl memmove(void *_Dst,const void *_Src,size_t _Size) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("_strdup") +#undef _strdup +#endif _CRTIMP char *__cdecl _strdup(const char *_Src); +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("_strdup") +#endif _CONST_RETURN char *__cdecl strchr(const char *_Str,int _Val); _CRTIMP int __cdecl _stricmp(const char *_Str1,const char *_Str2); _CRTIMP int __cdecl _strcmpi(const char *_Str1,const char *_Str2); @@ -105,7 +112,14 @@ extern "C" { _CRTIMP size_t __cdecl _strxfrm_l(char * __restrict__ _Dst,const char * __restrict__ _Src,size_t _MaxCount,_locale_t _Locale); #ifndef NO_OLDNAMES +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("strdup") +#undef strdup +#endif char *__cdecl strdup(const char *_Src) __MINGW_ATTRIB_DEPRECATED_MSVC2005; +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("strdup") +#endif int __cdecl strcmpi(const char *_Str1,const char *_Str2) __MINGW_ATTRIB_DEPRECATED_MSVC2005; int __cdecl stricmp(const char *_Str1,const char *_Str2) __MINGW_ATTRIB_DEPRECATED_MSVC2005; char *__cdecl strlwr(char *_Str) __MINGW_ATTRIB_DEPRECATED_MSVC2005; @@ -128,7 +142,14 @@ extern "C" { #ifndef _WSTRING_DEFINED #define _WSTRING_DEFINED +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("_wcsdup") +#undef _wcsdup +#endif _CRTIMP wchar_t *__cdecl _wcsdup(const wchar_t *_Str); +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("_wcsdup") +#endif wchar_t *__cdecl wcscat(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Source) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; _CONST_RETURN wchar_t *__cdecl wcschr(const wchar_t *_Str,wchar_t _Ch); int __cdecl wcscmp(const wchar_t *_Str1,const wchar_t *_Str2); @@ -177,7 +198,14 @@ extern "C" { _CRTIMP int __cdecl _wcsnicoll_l(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount,_locale_t _Locale); #ifndef NO_OLDNAMES +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("wcsdup") +#undef wcsdup +#endif wchar_t *__cdecl wcsdup(const wchar_t *_Str) __MINGW_ATTRIB_DEPRECATED_MSVC2005; +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("wcsdup") +#endif #define wcswcs wcsstr int __cdecl wcsicmp(const wchar_t *_Str1,const wchar_t *_Str2) __MINGW_ATTRIB_DEPRECATED_MSVC2005; int __cdecl wcsnicmp(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount) __MINGW_ATTRIB_DEPRECATED_MSVC2005; diff --git a/mingw-w64-headers/crt/wchar.h b/mingw-w64-headers/crt/wchar.h index 29323a6d95c6..34df93ec2470 100644 --- a/mingw-w64-headers/crt/wchar.h +++ b/mingw-w64-headers/crt/wchar.h @@ -253,10 +253,23 @@ _CRTIMP FILE *__cdecl __acrt_iob_func(unsigned index); #ifndef _WDIRECT_DEFINED #define _WDIRECT_DEFINED +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("_wgetcwd") +#undef _wgetcwd +#pragma push_macro("_wgetdcwd") +#undef _wgetdcwd +#pragma push_macro("_wgetdcwd_nolock") +#undef _wgetdcwd_nolock +#endif _CRTIMP wchar_t *__cdecl _wgetcwd(wchar_t *_DstBuf,int _SizeInWords); _CRTIMP wchar_t *__cdecl _wgetdcwd(int _Drive,wchar_t *_DstBuf,int _SizeInWords); #if __MSVCRT_VERSION__ >= 0x800 wchar_t *__cdecl _wgetdcwd_nolock(int _Drive,wchar_t *_DstBuf,int _SizeInWords); +#endif +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("_wgetcwd") +#pragma pop_macro("_wgetdcwd") +#pragma pop_macro("_wgetdcwd_nolock") #endif _CRTIMP int __cdecl _wchdir(const wchar_t *_Path); _CRTIMP int __cdecl _wmkdir(const wchar_t *_Path); @@ -1117,7 +1130,15 @@ __MINGW_ASM_CALL(__mingw_vsnwprintf); #endif #endif +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("_wtempnam") +#undef _wtempnam +#endif _CRTIMP wchar_t *__cdecl _wtempnam(const wchar_t *_Directory,const wchar_t *_FilePrefix); +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("_wtempnam") +#endif + #ifndef _UCRT _CRTIMP int __cdecl _vscwprintf(const wchar_t * __restrict__ _Format,va_list _ArgList); _CRTIMP int __cdecl _vscwprintf_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList); @@ -1223,7 +1244,14 @@ __MINGW_ASM_CALL(__mingw_vsnwprintf); #ifndef _POSIX_ #ifndef _WSTDLIBP_DEFINED #define _WSTDLIBP_DEFINED +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("_wfullpath") +#undef _wfullpath +#endif _CRTIMP wchar_t *__cdecl _wfullpath(wchar_t *_FullPath,const wchar_t *_Path,size_t _SizeInWords); +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("_wfullpath") +#endif _CRTIMP void __cdecl _wmakepath(wchar_t *_ResultPath,const wchar_t *_Drive,const wchar_t *_Dir,const wchar_t *_Filename,const wchar_t *_Ext); #ifndef _CRT_WPERROR_DEFINED #define _CRT_WPERROR_DEFINED @@ -1237,7 +1265,14 @@ __MINGW_ASM_CALL(__mingw_vsnwprintf); #ifndef _WSTRING_DEFINED #define _WSTRING_DEFINED +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("_wcsdup") +#undef _wcsdup +#endif _CRTIMP wchar_t *__cdecl _wcsdup(const wchar_t *_Str); +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("_wcsdup") +#endif wchar_t *__cdecl wcscat(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Source) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; _CONST_RETURN wchar_t *__cdecl wcschr(const wchar_t *_Str,wchar_t _Ch); int __cdecl wcscmp(const wchar_t *_Str1,const wchar_t *_Str2); @@ -1286,7 +1321,14 @@ __MINGW_ASM_CALL(__mingw_vsnwprintf); _CRTIMP int __cdecl _wcsnicoll_l(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount,_locale_t _Locale); #ifndef NO_OLDNAMES +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma push_macro("wcsdup") +#undef wcsdup +#endif wchar_t *__cdecl wcsdup(const wchar_t *_Str) __MINGW_ATTRIB_DEPRECATED_MSVC2005; +#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC) +#pragma pop_macro("wcsdup") +#endif #define wcswcs wcsstr int __cdecl wcsicmp(const wchar_t *_Str1,const wchar_t *_Str2) __MINGW_ATTRIB_DEPRECATED_MSVC2005; int __cdecl wcsnicmp(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount) __MINGW_ATTRIB_DEPRECATED_MSVC2005; -- 2.20.1 _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public