summaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-01-31 02:30:28 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-01-31 02:30:28 +0000
commit966b40288149e49be78f16a6e245a797c929238f (patch)
tree98b38ac8cee2983dc549b4f4f5892ea1e219263a /content
parent9085c458d3203a5feb1dbcb75658615ddd53ccae (diff)
downloadnetsurf-966b40288149e49be78f16a6e245a797c929238f.tar.gz
netsurf-966b40288149e49be78f16a6e245a797c929238f.tar.bz2
urldb_destroy_path_tree() -> iteration
svn path=/trunk/netsurf/; revision=6315
Diffstat (limited to 'content')
-rw-r--r--content/urldb.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/content/urldb.c b/content/urldb.c
index 4dec77dad..2f0ff6533 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -3864,17 +3864,32 @@ void urldb_destroy_host_tree(struct host_part *root)
*/
void urldb_destroy_path_tree(struct path_data *root)
{
- struct path_data *p, *q;
+ struct path_data *p = root;
- /* Destroy children */
- for (p = root->children; p; p = q) {
- q = p->next;
- urldb_destroy_path_tree(p);
- }
+ do {
+ if (p->children != NULL) {
+ p = p->children;
+ } else {
+ struct path_data *q = p;
- /* And ourselves */
- urldb_destroy_path_node_content(root);
- free(root);
+ while (p != root) {
+ if (p->next != NULL) {
+ p = p->next;
+ break;
+ }
+
+ p = p->parent;
+
+ urldb_destroy_path_node_content(q);
+ free(q);
+
+ q = p;
+ }
+
+ urldb_destroy_path_node_content(q);
+ free(q);
+ }
+ } while (p != root);
}
/**