Skip to content

Commit

Permalink
fixup radix: fixed radix iterators arithmetic issue
Browse files Browse the repository at this point in the history
Signed-off-by: John Sanpe <[email protected]>
  • Loading branch information
sanpeqf committed Jan 2, 2025
1 parent 06d89ad commit e61fe7b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
14 changes: 8 additions & 6 deletions src/radix.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,15 +402,16 @@ bfdev_radix_root_next(bfdev_radix_root_t *root, uintptr_t *offsetp)
node = parents[level].node;
index = parents[level].index;

count = radix_depth_shift(level - 1);
*offsetp &= ~((uintptr_t)RADIX_ARY_MASK << count);

while (++index < BFDEV_RADIX_ARY) {
if (!node->child[index])
continue;

count = radix_depth_shift(level - 1);
*offsetp &= ~((uintptr_t)RADIX_ARY_MASK << count);
*offsetp |= (uintptr_t)index << count;

node = node->child[index];

goto downward;
}
}
Expand Down Expand Up @@ -457,15 +458,16 @@ bfdev_radix_root_prev(bfdev_radix_root_t *root, uintptr_t *offsetp)
node = parents[level].node;
index = parents[level].index;

count = radix_depth_shift(level - 1);
*offsetp &= ~((uintptr_t)RADIX_ARY_MASK << count);

while (index--) {
if (!node->child[index])
continue;

count = radix_depth_shift(level - 1);
*offsetp &= ~((uintptr_t)RADIX_ARY_MASK << count);
*offsetp |= (uintptr_t)index << count;

node = node->child[index];

goto downward;
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/rbtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,7 @@ bfdev_rb_replace(bfdev_rb_root_t *root, bfdev_rb_node_t *oldn,
}

export bfdev_rb_node_t *
bfdev_rb_find(const bfdev_rb_root_t *root, void *key,
bfdev_rb_find_t find)
bfdev_rb_find(const bfdev_rb_root_t *root, void *key, bfdev_rb_find_t find)
{
bfdev_rb_node_t *node;
long retval;
Expand Down

0 comments on commit e61fe7b

Please sign in to comment.