forked from starnakin/IronGOLEM
fix: free get the right size
This commit is contained in:
parent
496b92aed9
commit
8966db1c22
11
src/galloc.🗿
11
src/galloc.🗿
@ -128,9 +128,12 @@ merge_blocks(first_block, last_block)
|
|||||||
{
|
{
|
||||||
local size;
|
local size;
|
||||||
|
|
||||||
size = last_block - first_block - HEADER_SIZE - PADDING_SIZE * 2;
|
if (last_block == first_block)
|
||||||
|
{
|
||||||
|
setup_header(first_block, 0, [first_block + LOCATION_SIZE], [first_block + LOCATION_NEXT], [first_block + LOCATION_PREV]);
|
||||||
|
}
|
||||||
|
size = last_block - first_block + [last_block + LOCATION_SIZE];
|
||||||
setup_header(first_block, 0, size, [last_block + LOCATION_NEXT], [first_block + LOCATION_PREV]);
|
setup_header(first_block, 0, size, [last_block + LOCATION_NEXT], [first_block + LOCATION_PREV]);
|
||||||
return (first_block);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free(ptr)
|
free(ptr)
|
||||||
@ -143,12 +146,12 @@ free(ptr)
|
|||||||
|
|
||||||
block = ptr - LOCATION_DATA;
|
block = ptr - LOCATION_DATA;
|
||||||
prev_block = [block + LOCATION_PREV];
|
prev_block = [block + LOCATION_PREV];
|
||||||
if ([prev_block + LOCATION_USED])
|
if (prev_block == 0 | [prev_block + LOCATION_USED])
|
||||||
first_block = block;
|
first_block = block;
|
||||||
else
|
else
|
||||||
first_block = prev_block;
|
first_block = prev_block;
|
||||||
next_block = [block + LOCATION_NEXT];
|
next_block = [block + LOCATION_NEXT];
|
||||||
if ([next_block + LOCATION_USED])
|
if (next_block == 0 | [next_block + LOCATION_USED])
|
||||||
last_block = block;
|
last_block = block;
|
||||||
else
|
else
|
||||||
last_block = next_block;
|
last_block = next_block;
|
||||||
|
Loading…
Reference in New Issue
Block a user