diff -r 85f55abea563 -r 98da78a1e69a src/ucx/avl.h --- a/src/ucx/avl.h Thu May 03 10:09:49 2018 +0200 +++ b/src/ucx/avl.h Thu May 03 10:44:33 2018 +0200 @@ -135,11 +135,36 @@ /** * Destroys a UcxAVLTree. + * + * Note, that the contents are not automatically freed. + * Use may use #ucx_avl_free_content() before calling this function. + * * @param tree the tree to destroy + * @see ucx_avl_free_content() */ void ucx_avl_free(UcxAVLTree *tree); /** + * Frees the contents of a UcxAVLTree. + * + * This is a convenience function that iterates over the tree and passes all + * values to the specified destructor function. + * + * If no destructor is specified (NULL), the free() function of + * the tree's own allocator is used. + * + * You must ensure, that it is valid to pass each value in the map to the same + * destructor function. + * + * You should free the entire tree afterwards, as the contents will be invalid. + * + * @param tree for which the contents shall be freed + * @param destr optional pointer to a destructor function + * @see ucx_avl_free() + */ +void ucx_avl_free_content(UcxAVLTree *tree, ucx_destructor destr); + +/** * Macro for initializing a new UcxAVLTree with the default allocator and a * ucx_ptrcmp() compare function. *