memory leak: when freeing factions, also free their spellbooks

This commit is contained in:
Enno Rehling 2015-10-13 21:47:45 +02:00
parent ff0bbce4f9
commit 2f35246f8c
3 changed files with 9 additions and 3 deletions

View File

@ -86,6 +86,7 @@ void free_faction(faction * f)
}
freelist(f->allies);
free_spellbook(f->spellbook);
free(f->email);
free(f->banner);
free(f->passw);

View File

@ -2984,11 +2984,15 @@ spellbook * get_spellbook(const char * name)
return result;
}
int free_spellbook_cb(const void *match, const void *key, size_t keylen, void *data) {
spellbook *sb;
cb_get_kv(match, &sb, sizeof(sb));
void free_spellbook(spellbook *sb) {
spellbook_clear(sb);
free(sb);
}
static int free_spellbook_cb(const void *match, const void *key, size_t keylen, void *data) {
spellbook *sb;
cb_get_kv(match, &sb, sizeof(sb));
free_spellbook(sb);
return 0;
}

View File

@ -363,6 +363,7 @@ extern "C" {
struct spellbook * get_spellbook(const char * name);
void free_spellbooks(void);
void free_spellbook(struct spellbook *sb);
#ifdef __cplusplus
}
#endif