summaryrefslogtreecommitdiff
path: root/render/box.c
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2002-09-08 18:11:56 +0000
committerJames Bursa <james@netsurf-browser.org>2002-09-08 18:11:56 +0000
commita46eef0002d061c3363756182a592be7646ae79b (patch)
tree3d347fb9f3dac906b2987c8eb20d8d6bbfd1ab22 /render/box.c
parenta21d245091e7f7d6ae6a9e08dc107b9dd495e4fb (diff)
downloadnetsurf-a46eef0002d061c3363756182a592be7646ae79b.tar.gz
netsurf-a46eef0002d061c3363756182a592be7646ae79b.tar.bz2
[project @ 2002-09-08 18:11:56 by bursa]
Add box_free(). svn path=/import/netsurf/; revision=32
Diffstat (limited to 'render/box.c')
-rw-r--r--render/box.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/render/box.c b/render/box.c
index beda7c153..94c550c69 100644
--- a/render/box.c
+++ b/render/box.c
@@ -1,5 +1,5 @@
/**
- * $Id: box.c,v 1.11 2002/08/18 16:46:45 bursa Exp $
+ * $Id: box.c,v 1.12 2002/09/08 18:11:56 bursa Exp $
*/
#include <assert.h>
@@ -231,7 +231,7 @@ struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style,
}
-/*
+/**
* get the style for an element
*/
@@ -288,7 +288,7 @@ struct css_style * box_get_style(struct css_stylesheet * stylesheet, struct css_
}
-/*
+/**
* print a box tree to standard output
*/
@@ -329,8 +329,8 @@ void box_dump(struct box * box, unsigned int depth)
}
-/*
- * ensure the box tree is correctly nested
+/**
+ * ensure the box tree is correctly nested
*/
void box_normalise_block(struct box *block)
@@ -607,3 +607,28 @@ void box_normalise_inline_container(struct box *cont)
}
}
}
+
+
+/**
+ * free a box tree recursively
+ */
+
+void box_free(struct box *box)
+{
+ /* free children first */
+ if (box->children != 0)
+ box_free(box->children);
+
+ /* then siblings */
+ if (box->next != 0)
+ box_free(box->next);
+
+ /* last this box */
+ if (box->style != 0)
+ free(box->style);
+ if (box->text != 0)
+ free(box->text);
+ /* only free href if we're the top most user */
+ if (box->href != 0 && (box->parent == 0 || box->parent->href != box->href))
+ free(box->href);
+}