Oops, fix typo in last patch.
[gnulib.git] / lib / gl_rbtree_oset.c
index 78636d6..936709d 100644 (file)
@@ -1,5 +1,5 @@
 /* Ordered set data type implemented by a binary tree.
-   Copyright (C) 2006 Free Software Foundation, Inc.
+   Copyright (C) 2006-2007 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2006.
 
    This program is free software; you can redistribute it and/or modify
@@ -542,8 +542,7 @@ static gl_oset_node_t
 gl_tree_add_first (gl_oset_t set, const void *elt)
 {
   /* Create new node.  */
-  gl_oset_node_t new_node =
-    (struct gl_oset_node_impl *) xmalloc (sizeof (struct gl_oset_node_impl));
+  gl_oset_node_t new_node = XMALLOC (struct gl_oset_node_impl);
 
   new_node->left = NULL;
   new_node->right = NULL;
@@ -578,8 +577,7 @@ static gl_oset_node_t
 gl_tree_add_before (gl_oset_t set, gl_oset_node_t node, const void *elt)
 {
   /* Create new node.  */
-  gl_oset_node_t new_node =
-    (struct gl_oset_node_impl *) xmalloc (sizeof (struct gl_oset_node_impl));
+  gl_oset_node_t new_node = XMALLOC (struct gl_oset_node_impl);
 
   new_node->left = NULL;
   new_node->right = NULL;
@@ -607,8 +605,7 @@ static gl_oset_node_t
 gl_tree_add_after (gl_oset_t set, gl_oset_node_t node, const void *elt)
 {
   /* Create new node.  */
-  gl_oset_node_t new_node =
-    (struct gl_oset_node_impl *) xmalloc (sizeof (struct gl_oset_node_impl));
+  gl_oset_node_t new_node = XMALLOC (struct gl_oset_node_impl);
 
   new_node->left = NULL;
   new_node->right = NULL;
@@ -752,6 +749,8 @@ gl_tree_remove_node (gl_oset_t set, gl_oset_node_t node)
     }
 
   set->count--;
+  if (set->base.dispose_fn != NULL)
+    set->base.dispose_fn (node->value);
   free (node);
   return true;
 }