Browse code

Implement av_tree_destroy_free_elem() to destroy a tree and free all the values stored on it.

Originally committed as revision 22119 to svn://svn.ffmpeg.org/ffmpeg/trunk

Vitor Sessak authored on 2010/03/01 05:48:42
Showing 2 changed files
... ...
@@ -135,6 +135,15 @@ void av_tree_destroy(AVTreeNode *t){
135 135
     }
136 136
 }
137 137
 
138
+void av_tree_destroy_free_elem(AVTreeNode *t){
139
+    if(t){
140
+        av_tree_destroy_free_elem(t->child[0]);
141
+        av_tree_destroy_free_elem(t->child[1]);
142
+        av_free(t->elem);
143
+        av_free(t);
144
+    }
145
+}
146
+
138 147
 #if 0
139 148
 void av_tree_enumerate(AVTreeNode *t, void *opaque, int (*cmp)(void *opaque, void *elem), int (*enu)(void *opaque, void *elem)){
140 149
     if(t){
... ...
@@ -78,5 +78,6 @@ void *av_tree_find(const struct AVTreeNode *root, void *key, int (*cmp)(void *ke
78 78
  */
79 79
 void *av_tree_insert(struct AVTreeNode **rootp, void *key, int (*cmp)(void *key, const void *b), struct AVTreeNode **next);
80 80
 void av_tree_destroy(struct AVTreeNode *t);
81
+void av_tree_destroy_free_elem(struct AVTreeNode *t);
81 82
 
82 83
 #endif /* AVUTIL_TREE_H */