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;
|
global heap[HEAP_SIZE] = 0;
|
||||||
|
|
||||||
define PADDING_SIZE = 4;
|
define PADDING_SIZE = 4;
|
||||||
define HEADER_SIZE = 5;
|
define HEADER_SIZE = 5;
|
||||||
|
|
||||||
🗿HEADER REPRESENTATION
|
🗿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 |
|
🗿| 1 case | 1 case | 1 case | 1 case | 1 case | 4 cases | n cases | 4 cases |
|
||||||
🗿+-------------+--------+--------+---------------------------+-------------------------------+---------+---------+---------+
|
🗿+-------------+--------+--------+-------------------------------+---------------------------+---------+---------+---------+
|
||||||
|
|
||||||
🗿 INITIALISED
|
🗿 INITIALISED
|
||||||
🗿 a boolean to state if the block is initialised
|
🗿 a boolean to state if the block is initialised
|
||||||
@ -29,8 +29,8 @@ define HEADER_SIZE = 5;
|
|||||||
define LOCATION_INITIALISED = 0;
|
define LOCATION_INITIALISED = 0;
|
||||||
define LOCATION_USED = 1;
|
define LOCATION_USED = 1;
|
||||||
define LOCATION_SIZE = 2;
|
define LOCATION_SIZE = 2;
|
||||||
define LOCATION_NEXT = 3;
|
define LOCATION_PREV = 3;
|
||||||
define LOCATION_PREV = 4;
|
define LOCATION_NEXT = 4;
|
||||||
define LOCATION_DATA = HEADER_SIZE + PADDING_SIZE;
|
define LOCATION_DATA = HEADER_SIZE + PADDING_SIZE;
|
||||||
|
|
||||||
setup_header(ptr, used, size, next_block, prev_block)
|
setup_header(ptr, used, size, next_block, prev_block)
|
||||||
@ -94,7 +94,7 @@ split_block(ptr, size)
|
|||||||
local old_size;
|
local old_size;
|
||||||
|
|
||||||
old_size = [ptr + LOCATION_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);
|
return (0);
|
||||||
old_next = [ptr + LOCATION_NEXT];
|
old_next = [ptr + LOCATION_NEXT];
|
||||||
next = ptr + size + HEADER_SIZE + PADDING_SIZE * 2;
|
next = ptr + size + HEADER_SIZE + PADDING_SIZE * 2;
|
||||||
|
Loading…
Reference in New Issue
Block a user