diff --git a/src/kernel/faction.c b/src/kernel/faction.c index f477b0858..d9c701a41 100644 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -288,7 +288,8 @@ void destroyfaction(faction * f) return; fset(f, FFL_QUIT); - spellbook_free(f->spellbook); + spellbook_clear(f->spellbook); + free(f->spellbook); f->spellbook = 0; while (f->battles) { diff --git a/src/kernel/spellbook.c b/src/kernel/spellbook.c index 5002c14d1..ad2a4c496 100644 --- a/src/kernel/spellbook.c +++ b/src/kernel/spellbook.c @@ -6,6 +6,8 @@ #include "spellbook.h" +#include + spellbook * create_spellbook(const char * name) { spellbook *result = (spellbook *)malloc(sizeof(spellbook)); @@ -24,7 +26,7 @@ void spellbook_add(spellbook *sb, struct spell * sp, int level) ql_push(&sb->spells, sbe); } -void spellbook_free(spellbook *sb) +void spellbook_clear(spellbook *sb) { quicklist *ql; int qi; diff --git a/src/kernel/spellbook.h b/src/kernel/spellbook.h index 6e5cc5ea3..81eb23a4b 100644 --- a/src/kernel/spellbook.h +++ b/src/kernel/spellbook.h @@ -41,7 +41,7 @@ spellbook * create_spellbook(const char * name); void spellbook_add(spellbook *sbp, struct spell * sp, int level); int spellbook_foreach(spellbook *sb, int (*callback)(spellbook_entry *, void *), void * data); -void spellbook_free(spellbook *sb); +void spellbook_clear(spellbook *sb); spellbook_entry * spellbook_get(spellbook *sb, struct spell * sp); #ifdef __cplusplus diff --git a/src/kernel/spellbook_test.c b/src/kernel/spellbook_test.c index 29b3bd4b7..c875a1941 100644 --- a/src/kernel/spellbook_test.c +++ b/src/kernel/spellbook_test.c @@ -51,7 +51,8 @@ void test_named_spellbooks(CuTest * tc) spellbook_foreach(sb, count_spell_cb, &counter); CuAssertIntEquals(tc, 1, counter); #endif - spellbook_free(sb); + spellbook_clear(sb); + free(sb); } CuSuite *get_spellbook_suite(void)