summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/util/corealloc.c
diff options
context:
space:
mode:
author balr0g <balrog032@gmail.com>2015-05-15 22:00:19 -0400
committer balr0g <balrog032@gmail.com>2015-05-16 15:57:07 -0400
commit79e17d0ad3c88cd5ef189ec55fc31b7ae91af825 (patch)
treef3b93e09257f82f78d3ec467241cb66f56e0c8cc /src/lib/util/corealloc.c
parent53635d12d7760da4713a5b26705ec0b0d0335ce7 (diff)
Remove nonstandard inline overloads (nw)
Diffstat (limited to 'src/lib/util/corealloc.c')
-rw-r--r--src/lib/util/corealloc.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/lib/util/corealloc.c b/src/lib/util/corealloc.c
index af4ec856887..8bc80c3b996 100644
--- a/src/lib/util/corealloc.c
+++ b/src/lib/util/corealloc.c
@@ -95,6 +95,32 @@ bool memory_entry::s_tracking = false;
memory_entry *memory_entry::s_hash[memory_entry::k_hash_prime] = { NULL };
memory_entry *memory_entry::s_freehead = NULL;
+//**************************************************************************
+// OPERATOR OVERLOADS - DEFINITIONS
+//**************************************************************************
+
+#ifndef NO_MEM_TRACKING
+
+// standard new/delete operators (try to avoid using)
+void *operator new(std::size_t size) throw (std::bad_alloc) { return malloc_file_line(size, NULL, 0, false, true, false); }
+void *operator new[](std::size_t size) throw (std::bad_alloc) { return malloc_file_line(size, NULL, 0, true, true, false); }
+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); }
+
+#endif
+
+// 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); }
+void operator delete(void *ptr, const char *file, int line) { if (ptr != NULL) free_file_line(ptr, file, line, false); }
+void operator delete[](void *ptr, const char *file, int line) { if (ptr != NULL) free_file_line(ptr, file, line, true); }
+
+// file/line new/delete operators with zeroing
+void *operator new(std::size_t size, const char *file, int line, const zeromem_t &) throw (std::bad_alloc) { return malloc_file_line(size, file, line, false, true, true); }
+void *operator new[](std::size_t size, const char *file, int line, const zeromem_t &) throw (std::bad_alloc) { return malloc_file_line(size, file, line, true, true, true); }
+void operator delete(void *ptr, const char *file, int line, const zeromem_t &) { if (ptr != NULL) free_file_line(ptr, file, line, false); }
+void operator delete[](void *ptr, const char *file, int line, const zeromem_t &) { if (ptr != NULL) free_file_line(ptr, file, line, true); }
+
//**************************************************************************