summaryrefslogtreecommitdiff
path: root/bk_html.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2004-06-27 13:04:24 +0000
committerSimon Tatham <anakin@pobox.com>2004-06-27 13:04:24 +0000
commit037337dcc8cc4e7f2f8a628ab73b1b461dae7171 (patch)
tree0e47b8902569c362ad7f75c95ae4e4cd062f5848 /bk_html.c
parentf6183ca90ff1cf0fc085f4aa147b1a65db5c84f3 (diff)
downloadhalibut-037337dcc8cc4e7f2f8a628ab73b1b461dae7171.zip
halibut-037337dcc8cc4e7f2f8a628ab73b1b461dae7171.tar.gz
halibut-037337dcc8cc4e7f2f8a628ab73b1b461dae7171.tar.bz2
halibut-037337dcc8cc4e7f2f8a628ab73b1b461dae7171.tar.xz
Free up all the data we allocated during the HTML backend.
[originally from svn r4316]
Diffstat (limited to 'bk_html.c')
-rw-r--r--bk_html.c73
1 files changed, 68 insertions, 5 deletions
diff --git a/bk_html.c b/bk_html.c
index d0e555e..86abd62 100644
--- a/bk_html.c
+++ b/bk_html.c
@@ -10,9 +10,6 @@
* sensible. Perhaps for the topmost section in the file, no
* fragment should be used? (Though it should probably still be
* _there_ even if unused.)
- *
- * - free up all the data we have allocated while running this
- * backend.
*/
#include <stdio.h>
@@ -465,7 +462,8 @@ paragraph *html_config_filename(char *filename)
}
void html_backend(paragraph *sourceform, keywordlist *keywords,
- indexdata *idx, void *unused) {
+ indexdata *idx, void *unused)
+{
paragraph *p;
htmlconfig conf;
htmlfilelist files = { NULL, NULL, NULL, NULL, NULL };
@@ -1401,8 +1399,73 @@ void html_backend(paragraph *sourceform, keywordlist *keywords,
}
/*
- * FIXME: Free all the working data.
+ * Free all the working data.
*/
+ sfree(conf.asect);
+ sfree(conf.single_filename);
+ sfree(conf.contents_filename);
+ sfree(conf.index_filename);
+ sfree(conf.template_filename);
+ sfree(conf.template_fragment);
+ {
+ htmlfragment *frag;
+ while ( (frag = (htmlfragment *)delpos234(files.frags, 0)) != NULL ) {
+ /*
+ * frag->fragment is dynamically allocated, but will be
+ * freed when we process the htmlsect structure which
+ * it is attached to.
+ */
+ sfree(frag);
+ }
+ freetree234(files.frags);
+ }
+ {
+ htmlsect *sect, *tmp;
+ sect = sects.head;
+ while (sect) {
+ tmp = sect->next;
+ sfree(sect->fragment);
+ sfree(sect);
+ sect = tmp;
+ }
+ sect = nonsects.head;
+ while (sect) {
+ tmp = sect->next;
+ sfree(sect->fragment);
+ sfree(sect);
+ sect = tmp;
+ }
+ }
+ {
+ htmlfile *file, *tmp;
+ file = files.head;
+ while (file) {
+ tmp = file->next;
+ sfree(file->filename);
+ sfree(file);
+ file = tmp;
+ }
+ }
+ {
+ int i;
+ indexentry *entry;
+ for (i = 0; (entry = index234(idx->entries, i)) != NULL; i++) {
+ htmlindex *hi = (htmlindex *)entry->backend_data;
+ sfree(hi);
+ }
+ }
+ {
+ paragraph *p;
+ word *w;
+ for (p = sourceform; p; p = p->next)
+ for (w = p->words; w; w = w->next)
+ if (w->type == word_IndexRef) {
+ htmlindexref *hr = (htmlindexref *)w->private_data;
+ assert(hr != NULL);
+ sfree(hr->fragment);
+ sfree(hr);
+ }
+ }
}
static void html_file_section(htmlconfig *cfg, htmlfilelist *files,