simple c99 compiler
git clone git://
Log | Files | Refs | Submodules | README | LICENSE

commit d84bdd272107e10208c8531b435590d017df410e
parent f257e561a1e9e01fff0014987a5050f9c2701406
Author: Roberto E. Vargas Caballero <>
Date:   Sun, 21 Nov 2021 17:53:40 +0100

libc: Merge&split correctly with next block

When the consecutive block is the next block we can merge it with
the block of realloc'ed pointer. In that case we have to remove
the next block from the free list, and insert the remaining part
of the merge in the list. To remove the next block we have to
modify the next pointer of the previous block and assign the next
block of the next pointer to the next pointer of the new block.

Msrc/libc/stdlib/realloc.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libc/stdlib/realloc.c b/src/libc/stdlib/realloc.c @@ -50,7 +50,7 @@ realloc(void *ptr, size_t nbytes) if (avail > nunits) { oh->h.size = nunits; prev-> = new; - new-> = next; + new-> = next->; new->h.size = avail - nunits; return oh + 1; }