Fix bug in the function that searches for the allocation header

This commit is contained in:
Abdelrahman Said 2024-03-24 17:24:33 +00:00
parent 3fdd897291
commit ca36e0dc35

View File

@ -337,7 +337,7 @@ internal ArenaAllocHDR *find_alloc_header(BaseArena *arena, void *alloc_ptr) {
max_search_end > arena_buf_start ? max_search_end : arena_buf_start; max_search_end > arena_buf_start ? max_search_end : arena_buf_start;
bool match; bool match;
while (current > search_end) { for (; current >= search_end; --current) {
match = true; match = true;
for (u64 i = 0; i < HDR_MAGIC_BYTE_COUNT; ++i) { for (u64 i = 0; i < HDR_MAGIC_BYTE_COUNT; ++i) {
@ -350,9 +350,7 @@ internal ArenaAllocHDR *find_alloc_header(BaseArena *arena, void *alloc_ptr) {
if (match) { if (match) {
return (ArenaAllocHDR *)current; return (ArenaAllocHDR *)current;
} }
}
current -= HDR_MAGIC_BYTE_COUNT;
}
return NULL; return NULL;
} }