forked from starnakin/IronGOLEM
core: invert prev and next pos
This commit is contained in:
parent
137eaac64f
commit
a69a870d49
14
src/galloc.🗿
14
src/galloc.🗿
@ -1,14 +1,14 @@
|
||||
define HEAP_SIZE = 0x020;
|
||||
define HEAP_SIZE = 0x030;
|
||||
global heap[HEAP_SIZE] = 0;
|
||||
|
||||
define PADDING_SIZE = 4;
|
||||
define HEADER_SIZE = 5;
|
||||
|
||||
🗿HEADER REPRESENTATION
|
||||
🗿+-------------+--------+--------+---------------------------+-------------------------------+---------+---------+---------+
|
||||
🗿| initialised | used | size | pointer to the next block | pointer to the previous block | padding | data | padding |
|
||||
🗿+-------------+--------+--------+-------------------------------+---------------------------+---------+---------+---------+
|
||||
🗿| initialised | used | size | pointer to the previous block | pointer to the next block | padding | data | padding |
|
||||
🗿| 1 case | 1 case | 1 case | 1 case | 1 case | 4 cases | n cases | 4 cases |
|
||||
🗿+-------------+--------+--------+---------------------------+-------------------------------+---------+---------+---------+
|
||||
🗿+-------------+--------+--------+-------------------------------+---------------------------+---------+---------+---------+
|
||||
|
||||
🗿 INITIALISED
|
||||
🗿 a boolean to state if the block is initialised
|
||||
@ -29,8 +29,8 @@ define HEADER_SIZE = 5;
|
||||
define LOCATION_INITIALISED = 0;
|
||||
define LOCATION_USED = 1;
|
||||
define LOCATION_SIZE = 2;
|
||||
define LOCATION_NEXT = 3;
|
||||
define LOCATION_PREV = 4;
|
||||
define LOCATION_PREV = 3;
|
||||
define LOCATION_NEXT = 4;
|
||||
define LOCATION_DATA = HEADER_SIZE + PADDING_SIZE;
|
||||
|
||||
setup_header(ptr, used, size, next_block, prev_block)
|
||||
@ -94,7 +94,7 @@ split_block(ptr, size)
|
||||
local old_size;
|
||||
|
||||
old_size = [ptr + LOCATION_SIZE];
|
||||
if (size + HEADER_SIZE >= [ptr + LOCATION_SIZE]) 🗿 if the block is to small to be split
|
||||
if (size + HEADER_SIZE + PADDING_SIZE * 2 > old_size) 🗿 if the block is to small to be split
|
||||
return (0);
|
||||
old_next = [ptr + LOCATION_NEXT];
|
||||
next = ptr + size + HEADER_SIZE + PADDING_SIZE * 2;
|
||||
|
Loading…
Reference in New Issue
Block a user