From edb3aa0d4e0217056f6e2cb96a32949a7e30ee0b Mon Sep 17 00:00:00 2001 From: Stanislav Paskalev Date: Fri, 20 Oct 2023 16:33:35 +0300 Subject: [PATCH] Update bench.c for new walk callback, remove a minor optimization that doesn't seem to add anything now (#89) --- bench.c | 7 +++++-- buddy_alloc.h | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bench.c b/bench.c index 2976ace..40c659c 100644 --- a/bench.c +++ b/bench.c @@ -16,7 +16,7 @@ double test_malloc(size_t alloc_size); double test_malloc_firstfit(size_t alloc_size); -void *freeing_callback(void *ctx, void *addr, size_t slot_size); +void *freeing_callback(void *ctx, void *addr, size_t slot_size, size_t allocated); int main() { setvbuf(stdout, NULL, _IONBF, 0); @@ -59,7 +59,10 @@ double test_malloc(size_t alloc_size) { return delta; } -void *freeing_callback(void *ctx, void *addr, size_t slot_size) { +void *freeing_callback(void *ctx, void *addr, size_t slot_size, size_t allocated) { + if (! allocated) { + return NULL; + } struct buddy *buddy = (struct buddy*) ctx; buddy_free(buddy, addr); return NULL; diff --git a/buddy_alloc.h b/buddy_alloc.h index f725463..b711c09 100644 --- a/buddy_alloc.h +++ b/buddy_alloc.h @@ -1628,7 +1628,6 @@ static struct buddy_tree_pos buddy_tree_find_free(struct buddy_tree *t, uint8_t current_pos = left_pos; } else { /* One of the child nodes must be read in order to compare it to its sibling. */ - right_internal.local_offset = target_status; /* reduce the read span since we know the right_status is equal or less than target_status */ right_status = read_from_internal_position(buddy_tree_bits(t), right_internal); if (right_status) { if (compare_with_internal_position(buddy_tree_bits(t), left_internal, right_status)) {