aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-05-02 21:28:38 +0200
committerThomas White <taw@bitwiz.me.uk>2019-05-02 21:28:38 +0200
commit417c11923591f7dd2df9bf0412aef4cee44afd74 (patch)
treee0d6bd0d03063ce05423e275d48fc8065f7f692a
parentea7a374be650bc5c5892d288b5869a1a2cabd78c (diff)
Free stylesheets properly
-rw-r--r--libstorycode/narrative.c1
-rw-r--r--libstorycode/stylesheet.c12
2 files changed, 13 insertions, 0 deletions
diff --git a/libstorycode/narrative.c b/libstorycode/narrative.c
index 7e58f88..7256651 100644
--- a/libstorycode/narrative.c
+++ b/libstorycode/narrative.c
@@ -84,6 +84,7 @@ static void narrative_item_destroy(struct narrative_item *item)
}
+/* Free the narrative and all contents, but not the stylesheet */
void narrative_free(Narrative *n)
{
int i;
diff --git a/libstorycode/stylesheet.c b/libstorycode/stylesheet.c
index c4625f2..2b549db 100644
--- a/libstorycode/stylesheet.c
+++ b/libstorycode/stylesheet.c
@@ -133,8 +133,20 @@ static void default_style(struct style *s)
}
+static void free_style_contents(struct style *sty)
+{
+ int i;
+ for ( i=0; i<sty->n_substyles; i++ ) {
+ free_style_contents(&sty->substyles[i]);
+ }
+ free(sty->name);
+ free(sty->substyles);
+}
+
+
void stylesheet_free(Stylesheet *s)
{
+ free_style_contents(&s->top);
free(s);
}