2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de
3 * Distributed under the terms of the MIT License.
5 #ifndef _KERNEL_DEBUG_HEAP_H
6 #define _KERNEL_DEBUG_HEAP_H
11 struct DebugAllocPool
;
12 typedef struct DebugAllocPool debug_alloc_pool
;
19 debug_alloc_pool
* create_debug_alloc_pool();
20 void delete_debug_alloc_pool(debug_alloc_pool
* pool
);
21 void* debug_malloc(size_t size
);
22 void* debug_calloc(size_t num
, size_t size
);
23 void debug_free(void* address
);
24 void debug_heap_init();
33 struct kdebug_alloc_t
{};
34 extern const kdebug_alloc_t kdebug_alloc
;
37 operator new(size_t size
, const kdebug_alloc_t
&) throw()
39 return debug_malloc(size
);
42 namespace DebugAlloc
{
43 template<typename Type
>
50 // NOTE: Doesn't work for multiple inheritence!
55 struct DebugAllocPoolScope
{
58 fPool
= create_debug_alloc_pool();
61 ~DebugAllocPoolScope()
63 delete_debug_alloc_pool(fPool
);
67 DebugAllocPool
* fPool
;
72 #endif /* _KERNEL_DEBUG_HEAP_H */