forked from starnakin/IronGOLEM
fix: last block is now right initialise
This commit is contained in:
parent
9d349d1528
commit
15c3f07692
@ -37,8 +37,6 @@ setup_header(ptr, used, size, next_block, prev_block)
|
||||
{
|
||||
local i;
|
||||
|
||||
if (size + PADDING_SIZE * 2 + HEADER_SIZE > HEAP_SIZE)
|
||||
return (1);
|
||||
[ptr + LOCATION_INITIALISED] = 1;
|
||||
[ptr + LOCATION_USED] = used;
|
||||
[ptr + LOCATION_SIZE] = size;
|
||||
@ -67,7 +65,7 @@ find_next_space(size)
|
||||
& [current + LOCATION_SIZE] >= size)
|
||||
return (current);
|
||||
current = [current + LOCATION_NEXT];
|
||||
if ([current] == 0)
|
||||
if (current == 0)
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
@ -95,7 +93,10 @@ split_block(ptr, size)
|
||||
|
||||
old_size = [ptr + LOCATION_SIZE];
|
||||
if (size + HEADER_SIZE + PADDING_SIZE * 2 > old_size) 🗿 if the block is to small to be split
|
||||
return (0);
|
||||
{
|
||||
[ptr + LOCATION_USED] = 1;
|
||||
return (ptr);
|
||||
}
|
||||
old_next = [ptr + LOCATION_NEXT];
|
||||
next = ptr + size + HEADER_SIZE + PADDING_SIZE * 2;
|
||||
prev = [ptr + LOCATION_PREV];
|
||||
|
@ -1,5 +1,10 @@
|
||||
main()
|
||||
{
|
||||
name = "galloc";
|
||||
test(galloc(1), heap + LOCATION_DATA, "");
|
||||
|
||||
dbg galloc(1);
|
||||
dbg galloc(1);
|
||||
dbg galloc(1);
|
||||
dbg galloc(1);
|
||||
dbg galloc(1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user