diff --git a/lib/sbi/sbi_heap.c b/lib/sbi/sbi_heap.c index e43d77c0..cc4893da 100644 --- a/lib/sbi/sbi_heap.c +++ b/lib/sbi/sbi_heap.c @@ -63,8 +63,9 @@ void *sbi_malloc_from(struct sbi_heap_control *hpctrl, size_t size) n = sbi_list_first_entry(&hpctrl->free_node_list, struct heap_node, head); sbi_list_del(&n->head); - n->addr = np->addr + np->size - size; + n->addr = np->addr; n->size = size; + np->addr += size; np->size -= size; sbi_list_add_tail(&n->head, &hpctrl->used_space_list); ret = (void *)n->addr;