Mercurial > libpst
diff src/libpst.c @ 287:0f0ccd29b0d7
use recursion to free a tree structure
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Tue, 24 May 2011 17:01:00 -0700 |
parents | 86078d0c2e9c |
children | cc8ee701f190 |
line wrap: on
line diff
--- 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();