summaryrefslogtreecommitdiff
path: root/render
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
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')
-rw-r--r--render/box.c35
-rw-r--r--render/box.h3
-rw-r--r--render/layout.c6
3 files changed, 35 insertions, 9 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);
+}
diff --git a/render/box.h b/render/box.h
index 50b2538fa..17bfcef4d 100644
--- a/render/box.h
+++ b/render/box.h
@@ -1,5 +1,5 @@
/**
- * $Id: box.h,v 1.7 2002/08/18 16:46:45 bursa Exp $
+ * $Id: box.h,v 1.8 2002/09/08 18:11:56 bursa Exp $
*/
#ifndef _NETSURF_RENDER_BOX_H_
@@ -45,5 +45,6 @@ void xml_to_box(xmlNode * n, struct css_style * parent_style, struct css_stylesh
struct box * parent, struct box * inline_container,
const char *href);
void box_dump(struct box * box, unsigned int depth);
+void box_free(struct box *box);
#endif
diff --git a/render/layout.c b/render/layout.c
index f2548d3cc..7d15fb11b 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -1,5 +1,5 @@
/**
- * $Id: layout.c,v 1.13 2002/08/18 16:46:45 bursa Exp $
+ * $Id: layout.c,v 1.14 2002/09/08 18:11:56 bursa Exp $
*/
#include <assert.h>
@@ -370,7 +370,7 @@ struct box * layout_line(struct box * first, unsigned long width, unsigned long
b = c->next;
} else {
c2 = memcpy(xcalloc(1, sizeof(struct box)), c, sizeof(struct box));
- c2->text = space + 1;
+ c2->text = xstrdup(space + 1);
c2->length = c->length - (c2->text - c->text);
c->length = space - c->text;
c2->next = c->next;
@@ -394,7 +394,7 @@ struct box * layout_line(struct box * first, unsigned long width, unsigned long
w = font_width(c->style, c->text, space2 - c->text);
}
c2 = memcpy(xcalloc(1, sizeof(struct box)), c, sizeof(struct box));
- c2->text = space + 1;
+ c2->text = xstrdup(space + 1);
c2->length = c->length - (c2->text - c->text);
c->length = space - c->text;
c2->next = c->next;