minor leak: release memory held by curse_type structures

This commit is contained in:
Enno Rehling 2015-10-15 08:38:43 +02:00
parent d4655ee88a
commit c9e7a76d9b
3 changed files with 14 additions and 2 deletions

View file

@ -16,6 +16,7 @@
#include <util/functions.h>
#include <kernel/xmlreader.h>
#include <kernel/item.h>
#include <kernel/curse.h>
#include <kernel/building.h>
#include <modules/gmcmd.h>
#include <modules/xmas.h>
@ -48,6 +49,7 @@ void game_done(void)
calendar_cleanup();
#endif
free_functions();
free_curses();
kernel_done();
}

View file

@ -293,11 +293,12 @@ attrib_type at_curse = {
#include <util/umlaut.h>
#include <quicklist.h>
static quicklist *cursetypes[256];
#define MAXCTHASH 128
static quicklist *cursetypes[MAXCTHASH];
void ct_register(const curse_type * ct)
{
unsigned int hash = tolower(ct->cname[0]);
unsigned int hash = tolower(ct->cname[0]) & 0xFF;
quicklist **ctlp = cursetypes + hash;
ql_set_insert(ctlp, (void *)ct);
@ -818,3 +819,10 @@ double destr_curse(curse * c, int cast_level, double force)
}
return force;
}
void free_curses(void) {
int i;
for (i = 0; i != MAXCTHASH; ++i) {
ql_free(cursetypes[i]);
}
}

View file

@ -214,6 +214,8 @@ extern "C" {
int duration; /* Dauer der Verzauberung. Wird jede Runde vermindert */
} curse;
void free_curses(void); /* de-register all curse-types */
extern struct attrib_type at_curse;
void curse_write(const struct attrib *a, const void *owner,
struct storage *store);