# HG changeset patch # User Carl Byington # Date 1306281660 25200 # Node ID 0f0ccd29b0d77876b858a415dbfa2db7226722bd # Parent ea7b2e4f474faf17b31e5a04c4dae2a41480f1ab use recursion to free a tree structure diff -r ea7b2e4f474f -r 0f0ccd29b0d7 src/libpst.c --- a/src/libpst.c Tue May 24 16:29:41 2011 -0700 +++ b/src/libpst.c Tue May 24 17:01:00 2011 -0700 @@ -3194,7 +3194,7 @@ pst_id2_tree *t; DEBUG_ENT("pst_free_id2"); while (head) { - if (head->child) pst_free_id2(head->child); + pst_free_id2(head->child); t = head->next; free(head); head = t; @@ -3219,20 +3219,9 @@ pst_desc_tree *t; DEBUG_ENT("pst_free_desc"); while (head) { - while (head->child) { - head = head->child; - } - - // point t to the next item + pst_free_desc(head->child); t = head->next; - if (!t && head->parent) { - t = head->parent; - t->child = NULL; // set the child to NULL so we don't come back here again! - } - - if (head) free(head); - else DIE(("head is NULL")); - + free(head); head = t; } DEBUG_RET();