mgetgroups: remove dependency on realloc-gnu
[gnulib.git] / lib / gl_anytree_list1.h
index c73a4f1..b93b51e 100644 (file)
@@ -1,5 +1,5 @@
 /* Sequential list data type implemented by a binary tree.
-   Copyright (C) 2006 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2006.
 
    This program is free software: you can redistribute it and/or modify
@@ -27,3 +27,15 @@ typedef struct
 
 /* A stack used for iterating across the elements.  */
 typedef iterstack_item_t iterstack_t[MAXHEIGHT];
+
+/* Free a non-empty subtree recursively.
+   This function is recursive and therefore not very fast.  */
+static void
+free_subtree (gl_list_node_t node)
+{
+  if (node->left != NULL)
+    free_subtree (node->left);
+  if (node->right != NULL)
+    free_subtree (node->right);
+  free (node);
+}