From 417c11923591f7dd2df9bf0412aef4cee44afd74 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 2 May 2019 21:28:38 +0200 Subject: Free stylesheets properly --- libstorycode/narrative.c | 1 + libstorycode/stylesheet.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) 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; in_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); } -- cgit v1.2.3