heap: Revert problematic size calculation
Minor heap fragmentation was not worth preventing
This commit is contained in:
parent
e578e09ff9
commit
fc87643922
1 changed files with 3 additions and 10 deletions
|
@ -83,7 +83,7 @@ static void _heap_free(heap_t *heap, u32 addr)
|
||||||
hnode_t *node = (hnode_t *)(addr - sizeof(hnode_t));
|
hnode_t *node = (hnode_t *)(addr - sizeof(hnode_t));
|
||||||
node->used = 0;
|
node->used = 0;
|
||||||
node = heap->first;
|
node = heap->first;
|
||||||
while (1)
|
while (node)
|
||||||
{
|
{
|
||||||
if (!node->used)
|
if (!node->used)
|
||||||
{
|
{
|
||||||
|
@ -95,14 +95,7 @@ static void _heap_free(heap_t *heap, u32 addr)
|
||||||
node->next->prev = node->prev;
|
node->next->prev = node->prev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (node->next)
|
node = node->next;
|
||||||
node = node->next;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
node->size = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +114,7 @@ void *malloc(u32 size)
|
||||||
void *calloc(u32 num, u32 size)
|
void *calloc(u32 num, u32 size)
|
||||||
{
|
{
|
||||||
void *res = (void *)_heap_alloc(&_heap, num * size, sizeof(hnode_t));
|
void *res = (void *)_heap_alloc(&_heap, num * size, sizeof(hnode_t));
|
||||||
memset(res, 0, ALIGN(num * size, sizeof(hnode_t)));
|
memset(res, 0, num * size);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue