summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/debug.cpp12
-rw-r--r--lib/gras_impl/debug.hpp6
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/debug.cpp b/lib/debug.cpp
index 474e83d..f2c3700 100644
--- a/lib/debug.cpp
+++ b/lib/debug.cpp
@@ -16,6 +16,18 @@
#include <gras_impl/debug.hpp>
+#ifdef MALLOC_DEBUG
+#include <cstdio>
+#include <cstdlib>
+
+void *operator new(std::size_t n) throw (std::bad_alloc)
+{
+ //static int malloc_count = 0;
+ //printf("malloc #%d -> size %u\n", malloc_count++, n);
+ return std::malloc(n);
+}
+#endif
+
#ifdef ASSERTING
struct DebugAssertPrinter
diff --git a/lib/gras_impl/debug.hpp b/lib/gras_impl/debug.hpp
index 077ac5d..a817e12 100644
--- a/lib/gras_impl/debug.hpp
+++ b/lib/gras_impl/debug.hpp
@@ -17,6 +17,12 @@
#ifndef INCLUDED_LIBGRAS_IMPL_DEBUG_HPP
#define INCLUDED_LIBGRAS_IMPL_DEBUG_HPP
+//#define MALLOC_DEBUG
+#ifdef MALLOC_DEBUG
+#include <stdexcept>
+extern void *operator new(std::size_t n) throw (std::bad_alloc);
+#endif
+
#include <iostream>
#include <stdexcept>
#include <boost/current_function.hpp>