diff --git a/src/galloc.🗿 b/src/galloc.🗿 index 5045173..9e7bca5 100644 --- a/src/galloc.🗿 +++ b/src/galloc.🗿 @@ -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]; diff --git a/tests/galloc.🗿 b/tests/galloc.🗿 index fb9d6ee..f0cf94d 100644 --- a/tests/galloc.🗿 +++ b/tests/galloc.🗿 @@ -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); }