forked from github/server
memory leak: when freeing factions, also free their spellbooks
This commit is contained in:
parent
ff0bbce4f9
commit
2f35246f8c
3 changed files with 9 additions and 3 deletions
|
@ -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);
|
||||
|
|
10
src/magic.c
10
src/magic.c
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue