X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fheap.c;h=a8fdd536580fad117bd86ff684cf9d9ea5decfc9;hb=38e4b28d370c5f9284b285a71518ae2b6bce125c;hp=fbff88b29eecd7cd33e5f3a29a9afbfd53432b7f;hpb=c6668f5ce555ff5550fa3d9ab1462e5a625f832c;p=tpg%2Facess2.git diff --git a/Kernel/heap.c b/Kernel/heap.c index fbff88b2..a8fdd536 100644 --- a/Kernel/heap.c +++ b/Kernel/heap.c @@ -251,7 +251,7 @@ void free(void *Ptr) // Alignment Check if( (Uint)Ptr & (sizeof(Uint)-1) ) { - Warning("free - Passed a non-aligned address (%p)\n", Ptr); + Warning("free - Passed a non-aligned address (%p)", Ptr); return; } @@ -265,7 +265,7 @@ void free(void *Ptr) // Check memory block - Header head = (void*)( (Uint)Ptr - sizeof(tHeapHead) ); if(head->Magic == MAGIC_FREE) { - Warning("free - Passed a freed block (%p)\n", head); + Warning("free - Passed a freed block (%p) by %p", head, __builtin_return_address(0)); return; } if(head->Magic != MAGIC_USED) { @@ -280,7 +280,7 @@ void free(void *Ptr) return; } if(foot->Magic != MAGIC_FOOT) { - Warning("free - Footer magic is invalid (%p, 0x%x)\n", head, foot->Magic); + Warning("free - Footer magic is invalid (%p, %p = 0x%x)\n", head, &foot->Magic, foot->Magic); return; } @@ -368,6 +368,22 @@ void *realloc(void *__ptr, size_t __size) return NULL; } +/** + * \fn void *calloc(size_t num, size_t size) + * \brief Allocate and Zero a buffer in memory + * \param num Number of elements + * \param size Size of each element + */ +void *calloc(size_t num, size_t size) +{ + void *ret = malloc(num*size); + if(ret == NULL) return NULL; + + memset( ret, 0, num*size ); + + return ret; +} + /** * \fn int IsHeap(void *Ptr) * \brief Checks if an address is a heap address @@ -428,3 +444,8 @@ void Heap_Dump() } } #endif + +// === EXPORTS === +EXPORT(malloc); +EXPORT(realloc); +EXPORT(free);