From 19f0f7053b9044dde67f9467d6faad48f2f488e2 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 3 Oct 2011 21:49:28 +0000 Subject: More talloc destructors for nsurls. svn path=/trunk/netsurf/; revision=12939 --- render/box_construct.c | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'render') diff --git a/render/box_construct.c b/render/box_construct.c index caa170477..e34e8d746 100644 --- a/render/box_construct.c +++ b/render/box_construct.c @@ -1578,6 +1578,21 @@ bool box_frameset(BOX_SPECIAL_PARAMS) return ok; } + +/** + * Destructor for content_html_frames, for elements + * + * \param b The frame params being destroyed. + * \return 0 to allow talloc to continue destroying the tree. + */ +static int box_frames_talloc_destructor(struct content_html_frames *f) +{ + if (f->url != NULL) + nsurl_unref(f->url); + + return 0; +} + bool box_create_frameset(struct content_html_frames *f, xmlNode *n, html_content *content) { unsigned int row, col, index, i; @@ -1646,6 +1661,9 @@ bool box_create_frameset(struct content_html_frames *f, xmlNode *n, f->scrolling = SCROLLING_NO; f->children = talloc_array(content, struct content_html_frames, (rows * cols)); + + talloc_set_destructor(f->children, box_frames_talloc_destructor); + for (row = 0; row < rows; row++) { for (col = 0; col < cols; col++) { index = (row * cols) + col; @@ -1705,9 +1723,9 @@ bool box_create_frameset(struct content_html_frames *f, xmlNode *n, if (url) { /* no self-references */ if (nsurl_compare(content->base_url, url, - NSURL_COMPLETE)) + NSURL_COMPLETE) == false) frame->url = url; - url = NULL; + url = NULL; } /* fill in specified values */ @@ -1763,6 +1781,21 @@ bool box_create_frameset(struct content_html_frames *f, xmlNode *n, } +/** + * Destructor for content_html_iframe, for