From 9d349d15287e64a2e598f84467e96ac66d01122b Mon Sep 17 00:00:00 2001 From: starnakin Date: Sat, 17 Jun 2023 00:11:42 +0200 Subject: [PATCH] fix: use define to replace literal value --- src/galloc.🗿 | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/galloc.🗿 b/src/galloc.🗿 index 49e97a2..5045173 100644 --- a/src/galloc.🗿 +++ b/src/galloc.🗿 @@ -39,11 +39,11 @@ setup_header(ptr, used, size, next_block, prev_block) if (size + PADDING_SIZE * 2 + HEADER_SIZE > HEAP_SIZE) return (1); - [ptr] = 1; 🗿 initialised - [ptr + 1] = used; 🗿 used - [ptr + 2] = size; 🗿 size - [ptr + 3] = next_block; 🗿 next block - [ptr + 4] = prev_block; 🗿 previous block + [ptr + LOCATION_INITIALISED] = 1; + [ptr + LOCATION_USED] = used; + [ptr + LOCATION_SIZE] = size; + [ptr + LOCATION_PREV] = prev_block; + [ptr + LOCATION_NEXT] = next_block; i = HEADER_SIZE; loop @@ -102,8 +102,6 @@ split_block(ptr, size) 🗿 setup_header(ptr, used, size, next_block, prev_block); 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); - dbg 0x7777; - dbg old_size - size - HEADER_SIZE - PADDING_SIZE * 2; return (0); }