简体   繁体   中英

Linux kernel rb tree

Is it valid to do the following

struct foo {
int data;
struct rb_node node
};
struct rb_root root;
/* Filling tree with kalloc'ed foo nodes */
struct rb_node *node=rb_first(&root);
while (node)
{
 struct rb_node *next=rb_next(node);
 kfree(node);
 node = next;
}
root=RB_ROOT;

In fact, I just want do foreach and clear at same time with linear time.

Explored rb_next implementation. It returns parent before right children. So, It is impossible to clear list this way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM