summaryrefslogtreecommitdiff
path: root/content/urldb.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-01-30 19:58:46 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-01-30 19:58:46 +0000
commit376ef0ca478eaf16d641de019b8e2e87672c4a3a (patch)
treeb2a79b0ca16b30f7c00b18a1990913d1325a08bc /content/urldb.c
parente5c07a3a82b081ca5a072bd49ea160aea1195a2b (diff)
downloadnetsurf-376ef0ca478eaf16d641de019b8e2e87672c4a3a.tar.gz
netsurf-376ef0ca478eaf16d641de019b8e2e87672c4a3a.tar.bz2
Make urldb_iterate_entries_path use iteration
svn path=/trunk/netsurf/; revision=6304
Diffstat (limited to 'content/urldb.c')
-rw-r--r--content/urldb.c66
1 files changed, 38 insertions, 28 deletions
diff --git a/content/urldb.c b/content/urldb.c
index 4eafc5e5e..d8a85d5ea 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -1406,39 +1406,49 @@ bool urldb_iterate_entries_path(const struct path_data *parent,
bool (*cookie_callback)(const char *domain,
const struct cookie_data *data))
{
- const struct path_data *p;
+ const struct path_data *p = parent;
- if (!parent->children) {
- /* leaf node */
+ do {
+ if (p->children != NULL) {
+ /* Drill down into children */
+ p = p->children;
+ } else {
+ /* All leaf nodes in the path tree should have an URL or
+ * cookies attached to them. If this is not the case, it
+ * indicates that there's a bug in the file loader/URL
+ * insertion code. Therefore, assert this here. */
+ assert(url_callback || cookie_callback);
- /* All leaf nodes in the path tree should have an URL or
- * cookies attached to them. If this is not the case, it
- * indicates that there's a bug in the file loader/URL
- * insertion code. Therefore, assert this here. */
- assert(url_callback || cookie_callback);
+ /** \todo handle fragments? */
+ if (url_callback) {
+ const struct url_internal_data *u = &p->urld;
- /** \todo handle fragments? */
- if (url_callback) {
- const struct url_internal_data *u = &parent->urld;
+ assert(p->url);
- assert(parent->url);
- if (!url_callback(parent->url,
- (const struct url_data *) u))
- return false;
- } else {
- if (parent->cookies && !cookie_callback(
- parent->cookies->domain,
- (const struct cookie_data *)
- parent->cookies))
- return false;
- }
- }
+ if (!url_callback(p->url,
+ (const struct url_data *) u))
+ return false;
+ } else {
+ if (p->cookies && !cookie_callback(
+ p->cookies->domain,
+ (const struct cookie_data *)
+ p->cookies))
+ return false;
+ }
- for (p = parent->children; p; p = p->next) {
- if (!urldb_iterate_entries_path(p,
- url_callback, cookie_callback))
- return false;
- }
+ /* Now, find next node to process. */
+ while (p != parent) {
+ if (p->next != NULL) {
+ /* Have a sibling, process that */
+ p = p->next;
+ break;
+ }
+
+ /* Ascend tree */
+ p = p->parent;
+ }
+ }
+ } while (p != parent);
return true;
}