diff --git a/dune/common/debug_allocator.hh b/dune/common/debug_allocator.hh index 58c5fad33feb8786ab514ab153049370c046f589..a3fadcbcd4d266bee3bb4a8180c3def55506cded 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 e69abb3c7bb2224927332b71205b50eaff0b8edd..0fbe5cf6c82f854b0901a05811f1ba06ba99f5d1 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>