2009-01-13 15:58:31

by zhp

[permalink] [raw]
Subject: Is there a 'radix_tree_destroy()' interface in radix-tree?

Hi, all,

I am now writing a kernel module for Linux, and need to use the
radix-tree implementation in kernel. (include/linux/radix-tree.h &
lib/radix-tree.c). However, I do not find any interface for me to
destroy the tree, i.e. remove all non-root nodes in the tree, and free
all of my elements inserted in the tree before (of course, the free_fn
should be passed in by the user).

Is there such an interface for lib users? If not, who can tell me what
should I do to perform such a destroy task without dirty work? It is
almost impossible for me to "lookup an element to check whether it's
in the tree, delete it if yes", because all possible keys are very
very large.

Also, I think it will be very useful for the kernel radix-tree module
if it provide such an interface:

radix_tree_destroy(struct radix_tree_root *rtree,
rtree_free_node_fn free_fn)

How about adding such an interface as a patch if I finally have to do
the dirty work?

Thanks.
zhp