Skip to content

Commit

Permalink
Update bench.c for new walk callback, remove a minor optimization tha…
Browse files Browse the repository at this point in the history
…t doesn't seem to add anything now (#89)
  • Loading branch information
spaskalev authored Oct 20, 2023
1 parent 95ce902 commit edb3aa0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 5 additions & 2 deletions bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion buddy_alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit edb3aa0

Please sign in to comment.