Feature #6222
Updated by Josef Sipek almost 7 years ago
If one wants to quickly empty out a tree, it makes sense to use @avl_destroy_nodes@ avl_destroy_nodes via @uu_avl_teardown@. uu_avl_teardown. The one unfortunate side effect is that after all the nodes are freed, one must destroy & create the avl tree. See avl.h's note: <pre> * 3. Use avl_destroy_nodes() to quickly process/free up any remaining nodes. * Note that once you use avl_destroy_nodes(), you can no longer * use any routine except avl_destroy_nodes() and avl_destoy(). </pre> Since libuutil stashes the comparator, and other @avl_create@ avl_create args in the @uu_avl_pool_t@ uu_avl_pool_t structure, we can add a helper function to do the destroy/create combo and save the library users some headaches and typing: <pre> void uu_avl_recreate(uu_avl_t *ap) { uu_avl_pool_t *pp = ap->ua_pool; avl_destroy(&ap->ua_tree); avl_create(&ap->ua_tree, &uu_avl_node_compare, pp->uap_objsize, pp->uap_nodeoffset); } </pre>