From 3c5998b7eec001f3c9a01022580d50a5a0bd1db5 Mon Sep 17 00:00:00 2001 From: balr0g Date: Sat, 16 May 2015 17:12:38 -0400 Subject: [PATCH] Mark replacements separate from overloads and remove unneeded prototypes (nw) --- src/lib/util/corealloc.c | 11 ++++++++++- src/lib/util/corealloc.h | 10 ---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/lib/util/corealloc.c b/src/lib/util/corealloc.c index 8bc80c3b996..1dd94081a38 100644 --- a/src/lib/util/corealloc.c +++ b/src/lib/util/corealloc.c @@ -96,7 +96,7 @@ memory_entry *memory_entry::s_hash[memory_entry::k_hash_prime] = { NULL }; memory_entry *memory_entry::s_freehead = NULL; //************************************************************************** -// OPERATOR OVERLOADS - DEFINITIONS +// OPERATOR REPLACEMENTS //************************************************************************** #ifndef NO_MEM_TRACKING @@ -107,8 +107,17 @@ void *operator new[](std::size_t size) throw (std::bad_alloc) { return malloc_fi void operator delete(void *ptr) throw() { if (ptr != NULL) free_file_line(ptr, NULL, 0, false); } void operator delete[](void *ptr) throw() { if (ptr != NULL) free_file_line(ptr, NULL, 0, true); } +void* operator new(std::size_t size,const std::nothrow_t&) throw() { return malloc_file_line(size, NULL, 0, false, false, false); } +void* operator new[](std::size_t size, const std::nothrow_t&) throw() { return malloc_file_line(size, NULL, 0, true, false, false); } +void operator delete(void* ptr, const std::nothrow_t&) throw() { if (ptr != NULL) free_file_line(ptr, NULL, 0, false); } +void operator delete[](void* ptr, const std::nothrow_t&) throw() { if (ptr != NULL) free_file_line(ptr, NULL, 0, true); } + #endif +//************************************************************************** +// OPERATOR OVERLOADS - DEFINITIONS +//************************************************************************** + // file/line new/delete operators void *operator new(std::size_t size, const char *file, int line) throw (std::bad_alloc) { return malloc_file_line(size, file, line, false, true, false); } void *operator new[](std::size_t size, const char *file, int line) throw (std::bad_alloc) { return malloc_file_line(size, file, line, true, true, false); } diff --git a/src/lib/util/corealloc.h b/src/lib/util/corealloc.h index f12bd8fedcb..eb97e643686 100644 --- a/src/lib/util/corealloc.h +++ b/src/lib/util/corealloc.h @@ -57,16 +57,6 @@ void dump_unfreed_mem(UINT64 start = 0); // zeromem_t is a dummy class used to tell new to zero memory after allocation class zeromem_t { }; -#ifndef NO_MEM_TRACKING - -// standard new/delete operators (try to avoid using) -void *operator new(std::size_t size) throw (std::bad_alloc); -void *operator new[](std::size_t size) throw (std::bad_alloc); -void operator delete(void *ptr) throw(); -void operator delete[](void *ptr) throw(); - -#endif - // file/line new/delete operators void *operator new(std::size_t size, const char *file, int line) throw (std::bad_alloc); void *operator new[](std::size_t size, const char *file, int line) throw (std::bad_alloc);