Linux内核rb树

时间:2012-06-09 06:21:36

标签: linux memory tree kernel malloc

执行以下操作是否有效

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;

事实上,我只是希望在线性时间内同时做到并清除。

1 个答案:

答案 0 :(得分:0)

探索rb_next实现。它在正确的孩子之前返回父母。 因此,不可能以这种方式清除列表。