changeset 852:ae61fe3a97b9 libavutil

Implement av_tree_destroy_free_elem() to destroy a tree and free all the values stored on it.
author vitor
date Sun, 28 Feb 2010 20:48:42 +0000
parents dc1f09cd2195
children e067fb9b7d68
files tree.c tree.h
diffstat 2 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tree.c	Sun Feb 28 02:32:16 2010 +0000
+++ b/tree.c	Sun Feb 28 20:48:42 2010 +0000
@@ -135,6 +135,15 @@
     }
 }
 
+void av_tree_destroy_free_elem(AVTreeNode *t){
+    if(t){
+        av_tree_destroy_free_elem(t->child[0]);
+        av_tree_destroy_free_elem(t->child[1]);
+        av_free(t->elem);
+        av_free(t);
+    }
+}
+
 #if 0
 void av_tree_enumerate(AVTreeNode *t, void *opaque, int (*cmp)(void *opaque, void *elem), int (*enu)(void *opaque, void *elem)){
     if(t){
--- a/tree.h	Sun Feb 28 02:32:16 2010 +0000
+++ b/tree.h	Sun Feb 28 20:48:42 2010 +0000
@@ -78,5 +78,6 @@
  */
 void *av_tree_insert(struct AVTreeNode **rootp, void *key, int (*cmp)(void *key, const void *b), struct AVTreeNode **next);
 void av_tree_destroy(struct AVTreeNode *t);
+void av_tree_destroy_free_elem(struct AVTreeNode *t);
 
 #endif /* AVUTIL_TREE_H */