summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2011-10-03 21:49:28 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2011-10-03 21:49:28 +0000
commit19f0f7053b9044dde67f9467d6faad48f2f488e2 (patch)
tree1ba6c60796ed6634d4ed7e6e2a6ce7a2104e6d1a /render
parent3043c58aaf60284f1d08c1d2b50b2e108b150564 (diff)
downloadnetsurf-19f0f7053b9044dde67f9467d6faad48f2f488e2.tar.gz
netsurf-19f0f7053b9044dde67f9467d6faad48f2f488e2.tar.bz2
More talloc destructors for nsurls.
svn path=/trunk/netsurf/; revision=12939
Diffstat (limited to 'render')
-rw-r--r--render/box_construct.c46
1 files changed, 41 insertions, 5 deletions
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 <frame> 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 */
@@ -1764,6 +1782,21 @@ bool box_create_frameset(struct content_html_frames *f, xmlNode *n,
/**
+ * Destructor for content_html_iframe, for <iframe> elements
+ *
+ * \param b The iframe params being destroyed.
+ * \return 0 to allow talloc to continue destroying the tree.
+ */
+static int box_iframes_talloc_destructor(struct content_html_iframe *f)
+{
+ if (f->url != NULL)
+ nsurl_unref(f->url);
+
+ return 0;
+}
+
+
+/**
* Inline subwindow [16.5].
*/
@@ -1809,6 +1842,9 @@ bool box_iframe(BOX_SPECIAL_PARAMS)
nsurl_unref(url);
return false;
}
+
+ talloc_set_destructor(iframe, box_iframes_talloc_destructor);
+
iframe->box = box;
iframe->margin_width = 0;
iframe->margin_height = 0;
@@ -1855,9 +1891,6 @@ bool box_iframe(BOX_SPECIAL_PARAMS)
xmlFree(s);
}
- /* release temporary memory */
- free(url);
-
/* box */
assert(box->style);
box->flags |= IFRAME;
@@ -2334,6 +2367,9 @@ bool box_embed(BOX_SPECIAL_PARAMS)
params = talloc(content, struct object_params);
if (!params)
return false;
+
+ talloc_set_destructor(params, box_object_talloc_destructor);
+
params->data = 0;
params->type = 0;
params->codetype = 0;