git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Usermode/libc - Minor fix to memmove
[tpg/acess2.git]
/
Usermode
/
Libraries
/
libc.so_src
/
heap.c
diff --git
a/Usermode/Libraries/libc.so_src/heap.c
b/Usermode/Libraries/libc.so_src/heap.c
index
d529f65
..
9b6799b
100644
(file)
--- a/
Usermode/Libraries/libc.so_src/heap.c
+++ b/
Usermode/Libraries/libc.so_src/heap.c
@@
-94,13
+94,16
@@
EXPORT void *malloc(size_t bytes)
//Corrupt Heap
\r
Heap_Dump();
\r
_SysDebug("malloc: Corrupt Heap\n");
\r
//Corrupt Heap
\r
Heap_Dump();
\r
_SysDebug("malloc: Corrupt Heap\n");
\r
+ exit(128);
\r
return NULL;
\r
}
\r
curBlock = (heap_head*)((uintptr_t)curBlock + curBlock->size);
\r
}
\r
\r
if((uintptr_t)curBlock < (uintptr_t)_heap_start) {
\r
return NULL;
\r
}
\r
curBlock = (heap_head*)((uintptr_t)curBlock + curBlock->size);
\r
}
\r
\r
if((uintptr_t)curBlock < (uintptr_t)_heap_start) {
\r
+ Heap_Dump();
\r
_SysDebug("malloc: Heap underrun for some reason\n");
\r
_SysDebug("malloc: Heap underrun for some reason\n");
\r
+ exit(128);
\r
return NULL;
\r
}
\r
\r
return NULL;
\r
}
\r
\r
@@
-174,7
+177,7
@@
EXPORT void *calloc(size_t __nmemb, size_t __size)
EXPORT void free(void *mem)
\r
{
\r
heap_head *head = (void*)((intptr_t)mem-sizeof(heap_head));
\r
EXPORT void free(void *mem)
\r
{
\r
heap_head *head = (void*)((intptr_t)mem-sizeof(heap_head));
\r
-
\r
+
\r
// Sanity please!
\r
if(!mem) return;
\r
\r
// Sanity please!
\r
if(!mem) return;
\r
\r
@@
-185,7
+188,7
@@
EXPORT void free(void *mem)
DEBUGS("free(%p) : 0x%x bytes", mem, head->size);
\r
\r
//Unify Right
\r
DEBUGS("free(%p) : 0x%x bytes", mem, head->size);
\r
\r
//Unify Right
\r
- if((
intptr_t)head + head->size < (
intptr_t)_heap_end)
\r
+ if((
uintptr_t)head + head->size < (u
intptr_t)_heap_end)
\r
{
\r
heap_head *nextHead = (heap_head*)((intptr_t)head + head->size);
\r
if(nextHead->magic == MAGIC_FREE) { //Is the next block free
\r
{
\r
heap_head *nextHead = (heap_head*)((intptr_t)head + head->size);
\r
if(nextHead->magic == MAGIC_FREE) { //Is the next block free
\r
@@
-194,7
+197,7
@@
EXPORT void free(void *mem)
}
\r
}
\r
//Unify Left
\r
}
\r
}
\r
//Unify Left
\r
- if((
intptr_t)head - sizeof(heap_foot) > (
intptr_t)_heap_start)
\r
+ if((
uintptr_t)head - sizeof(heap_foot) > (u
intptr_t)_heap_start)
\r
{
\r
heap_head *prevHead;
\r
heap_foot *prevFoot = (heap_foot *)((intptr_t)head - sizeof(heap_foot));
\r
{
\r
heap_head *prevHead;
\r
heap_foot *prevFoot = (heap_foot *)((intptr_t)head - sizeof(heap_foot));
\r
@@
-450,17
+453,15
@@
void Heap_Dump(void)
heap_head *cur = _heap_start;
\r
while( cur < (heap_head*)_heap_end )
\r
{
\r
heap_head *cur = _heap_start;
\r
while( cur < (heap_head*)_heap_end )
\r
{
\r
- switch( cur->magic )
\r
- {
\r
- case MAGIC:
\r
+ if( cur->magic == MAGIC ) {
\r
_SysDebug("Used block %p[0x%x] - ptr=%p", cur, cur->size, cur->data);
\r
_SysDebug("Used block %p[0x%x] - ptr=%p", cur, cur->size, cur->data);
\r
- break;
\r
- case MAGIC_FREE:
\r
+ }
\r
+ else if( cur->magic == MAGIC_FREE ) {
\r
_SysDebug("Free block %p[0x%x] - ptr=%p", cur, cur->size, cur->data);
\r
_SysDebug("Free block %p[0x%x] - ptr=%p", cur, cur->size, cur->data);
\r
- break;
\r
- default:
\r
+ }
\r
+ else {
\r
_SysDebug("Block %p bad magic (0x%x)", cur, cur->magic);
\r
_SysDebug("Block %p bad magic (0x%x)", cur, cur->magic);
\r
-
return
;
\r
+
break
;
\r
}
\r
cur = (void*)( (char*)cur + cur->size );
\r
}
\r
}
\r
cur = (void*)( (char*)cur + cur->size );
\r
}
\r
UCC
git Repository :: git.ucc.asn.au