From 6e5874cfdc046e57b7b7dfff1a63cac0bbf140ba Mon Sep 17 00:00:00 2001
From: Christian Engwer <christi@dune-project.org>
Date: Fri, 5 Oct 2012 09:11:40 +0000
Subject: [PATCH] [debugallocator] use mallocallocator for
 book-keeping-containers ... make new/delete work

[[Imported from SVN: r7010]]
---
 dune/common/debug_allocator.hh       | 13 +++++++++----
 dune/common/test/test-debug-alloc.cc |  2 +-
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/dune/common/debug_allocator.hh b/dune/common/debug_allocator.hh
index 58c5fad33..a3fadcbcd 100644
--- a/dune/common/debug_allocator.hh
+++ b/dune/common/debug_allocator.hh
@@ -5,11 +5,15 @@
 
 #include <exception>
 #include <typeinfo>
-#include <malloc.h>
 #include <sys/mman.h>
 #include <vector>
 #include <iostream>
 #include <cstring>
+#include <cstdlib>
+#include <malloc.h>
+#include <new>
+
+#include "mallocallocator.hh"
 
 namespace Dune
 {
@@ -47,7 +51,8 @@ namespace Dune
         bool not_free;
       };
 
-      typedef std::vector<AllocationInfo> AllocationList;
+      typedef MallocAllocator<AllocationInfo> Alloc;
+      typedef std::vector<AllocationInfo, Alloc> AllocationList;
       AllocationList allocation_list;
 
     private:
@@ -151,7 +156,7 @@ namespace Dune
             memprotect(it->page_ptr,
                        (it->pages) * page_size,
                        PROT_READ | PROT_WRITE);
-            free(it->page_ptr);
+            std::free(it->page_ptr);
             // remove chunk info
             allocation_list.erase(it);
 #endif
@@ -169,7 +174,7 @@ namespace Dune
   template<class T>
   class DebugAllocator;
 
-  // specialize for void:
+  // specialize for void
   template <>
   class DebugAllocator<void> {
   public:
diff --git a/dune/common/test/test-debug-alloc.cc b/dune/common/test/test-debug-alloc.cc
index e69abb3c7..0fbe5cf6c 100644
--- a/dune/common/test/test-debug-alloc.cc
+++ b/dune/common/test/test-debug-alloc.cc
@@ -5,7 +5,7 @@
 #endif
 
 // #define DEBUG_ALLOCATOR_KEEP 1
-// #define DEBUG_NEW_DELETE 3
+#define DEBUG_NEW_DELETE 3
 
 #include <dune/common/debug_allocator.hh>
 
-- 
GitLab