Kernel/heap - Clean up a little, fix corruption in realloc, add hacky watchpoints
[tpg/acess2.git] / KernelLand / Kernel / include / heap.h
1 /**
2  * Acess2 Kernel
3  * heap.h
4  * - Dynamic Memory Allocation exports
5  */
6
7 #ifndef _HEAP_H_
8 #define _HEAP_H_
9
10 extern void     *Heap_Allocate(const char *File, int Line, size_t Bytes);
11 extern void     *Heap_AllocateZero(const char *File, int Line, size_t Bytes);
12 extern void     *Heap_Reallocate(const char *File, int Line, void *Ptr, size_t Bytes);
13 extern void     Heap_Deallocate(const char *File, int Line, void *Ptr);
14 extern int      Heap_IsHeapAddr(void *Ptr);
15 extern void     Heap_Validate(void);
16 /**
17  * \brief Hint to the heap code to put a watchpoint on this block's memory
18  *
19  * Use sparingly, watchpoints are limited and/or very expensive (or not even implemented)
20  */
21 extern int      Heap_WatchBlock(void *Ptr);
22
23 #define malloc(size)    Heap_Allocate(_MODULE_NAME_"/"__FILE__, __LINE__, (size))
24 #define calloc(num,size)        Heap_AllocateZero(_MODULE_NAME_"/"__FILE__, __LINE__, (num)*(size))
25 #define realloc(ptr,size)       Heap_Reallocate(_MODULE_NAME_"/"__FILE__, __LINE__, (ptr), (size))
26 #define free(ptr)       Heap_Deallocate(_MODULE_NAME_"/"__FILE__,__LINE__,(ptr))
27 #define IsHeap(ptr)     Heap_IsHeapAddr((ptr))
28
29 #define strdup(Str)     _strdup(_MODULE_NAME_"/"__FILE__, __LINE__, (Str))
30
31 #endif

UCC git Repository :: git.ucc.asn.au