From 02d0e14bcaebad0a49f870b1ade67cc8db45c18d Mon Sep 17 00:00:00 2001 From: Martin Mitas Date: Thu, 16 Jan 2020 12:30:09 +0100 Subject: [PATCH] memorystat.h: Fix build with gcc 8.3.0. func() and std::func() may conflict, depending on what C++ options or stanadard or whatever the code including the header uses. --- src/memorystat.h | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/memorystat.h b/src/memorystat.h index fd6a9b31..745d218f 100644 --- a/src/memorystat.h +++ b/src/memorystat.h @@ -137,23 +137,31 @@ extern void MemoryStatFree(void* ptr); } #endif -#define malloc MemoryStatMalloc -#define calloc MemoryStatCalloc -#define realloc MemoryStatRealloc -#define free MemoryStatFree - #ifdef __cplusplus namespace std { - inline void* MemoryStatMalloc(size_t size) { + inline void* StdMemoryStatMalloc(size_t size) { return ::MemoryStatMalloc(size); } - inline void* MemoryStatRealloc(void* ptr, size_t size) { + inline void* StdMemoryStatCalloc(size_t num, size_t size) { + return ::MemoryStatCalloc(num, size); + } + inline void* StdMemoryStatRealloc(void* ptr, size_t size) { return ::MemoryStatRealloc(ptr, size); } - inline void MemoryStatFree(void* ptr) { + inline void StdMemoryStatFree(void* ptr) { return ::MemoryStatFree(ptr); } + + #define malloc StdMemoryStatMalloc + #define calloc StdMemoryStatCalloc + #define realloc StdMemoryStatRealloc + #define free StdMemoryStatFree }; +#else + #define malloc MemoryStatMalloc + #define calloc MemoryStatCalloc + #define realloc MemoryStatRealloc + #define free MemoryStatFree #endif #else // USE_MEMORYSTAT