forked from starnakin/IronGOLEM
fix: galloc: put function in 'static'
This commit is contained in:
parent
1f60f4eab0
commit
7e0c7180d3
28
src/galloc.🗿
28
src/galloc.🗿
@ -33,7 +33,7 @@ define LOCATION_PREV = 3;
|
|||||||
define LOCATION_NEXT = 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)
|
galloc_setup_header(ptr, used, size, next_block, prev_block)
|
||||||
{
|
{
|
||||||
local i;
|
local i;
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ setup_header(ptr, used, size, next_block, prev_block)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
find_next_space(size)
|
galloc_find_next_space(size)
|
||||||
{
|
{
|
||||||
local current;
|
local current;
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ find_next_space(size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print_heap()
|
galloc_print_heap()
|
||||||
{
|
{
|
||||||
local i;
|
local i;
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ print_heap()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
split_block(ptr, size)
|
galloc_split_block(ptr, size)
|
||||||
{
|
{
|
||||||
local old_next;
|
local old_next;
|
||||||
local next;
|
local next;
|
||||||
@ -100,9 +100,9 @@ split_block(ptr, size)
|
|||||||
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;
|
||||||
prev = [ptr + LOCATION_PREV];
|
prev = [ptr + LOCATION_PREV];
|
||||||
🗿 setup_header(ptr, used, size, next_block, prev_block);
|
🗿 galloc_setup_header(ptr, used, size, next_block, prev_block);
|
||||||
setup_header(ptr, 1, size, ptr + HEADER_SIZE + PADDING_SIZE * 2 + size, prev);
|
galloc_setup_header(ptr, 1, size, ptr + HEADER_SIZE + PADDING_SIZE * 2 + size, prev);
|
||||||
setup_header(next, 0, old_size - size - HEADER_SIZE - PADDING_SIZE * 2, old_next, ptr);
|
galloc_setup_header(next, 0, old_size - size - HEADER_SIZE - PADDING_SIZE * 2, old_next, ptr);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,8 +111,8 @@ galloc(size)
|
|||||||
local ptr;
|
local ptr;
|
||||||
|
|
||||||
if ([heap] == 0) 🗿 if the heap is not initialised
|
if ([heap] == 0) 🗿 if the heap is not initialised
|
||||||
setup_header(heap, 0, HEAP_SIZE - HEADER_SIZE - PADDING_SIZE * 2, 0, 0); 🗿 initialised all the heap
|
galloc_setup_header(heap, 0, HEAP_SIZE - HEADER_SIZE - PADDING_SIZE * 2, 0, 0); 🗿 initialised all the heap
|
||||||
ptr = find_next_space(size);
|
ptr = galloc_find_next_space(size);
|
||||||
if (ptr == 0)
|
if (ptr == 0)
|
||||||
return (0);
|
return (0);
|
||||||
if ([ptr + LOCATION_SIZE] == size)
|
if ([ptr + LOCATION_SIZE] == size)
|
||||||
@ -120,20 +120,20 @@ galloc(size)
|
|||||||
[ptr + LOCATION_USED] = 1;
|
[ptr + LOCATION_USED] = 1;
|
||||||
return (ptr + LOCATION_DATA);
|
return (ptr + LOCATION_DATA);
|
||||||
}
|
}
|
||||||
split_block(ptr, size);
|
galloc_split_block(ptr, size);
|
||||||
return (ptr + LOCATION_DATA);
|
return (ptr + LOCATION_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
merge_blocks(first_block, last_block)
|
galloc_merge_blocks(first_block, last_block)
|
||||||
{
|
{
|
||||||
local size;
|
local size;
|
||||||
|
|
||||||
if (last_block == first_block)
|
if (last_block == first_block)
|
||||||
{
|
{
|
||||||
setup_header(first_block, 0, [first_block + LOCATION_SIZE], [first_block + LOCATION_NEXT], [first_block + LOCATION_PREV]);
|
galloc_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];
|
size = last_block - first_block + [last_block + LOCATION_SIZE];
|
||||||
setup_header(first_block, 0, size, [last_block + LOCATION_NEXT], [first_block + LOCATION_PREV]);
|
galloc_setup_header(first_block, 0, size, [last_block + LOCATION_NEXT], [first_block + LOCATION_PREV]);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(ptr)
|
free(ptr)
|
||||||
@ -155,5 +155,5 @@ free(ptr)
|
|||||||
last_block = block;
|
last_block = block;
|
||||||
else
|
else
|
||||||
last_block = next_block;
|
last_block = next_block;
|
||||||
merge_blocks(first_block, last_block);
|
galloc_merge_blocks(first_block, last_block);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user