memory leak: free weapon data

This commit is contained in:
Enno Rehling 2015-10-13 22:27:43 +02:00
parent 0facb386a8
commit c70d987c09
2 changed files with 11 additions and 3 deletions

View File

@ -1178,12 +1178,17 @@ static item *default_spoil(const struct race *rc, int size)
return itm; return itm;
} }
int free_itype(item_type *itype) { static void free_itype(item_type *itype) {
free(itype->construction); free(itype->construction);
free(itype->_appearance[0]); free(itype->_appearance[0]);
free(itype->_appearance[1]); free(itype->_appearance[1]);
free(itype); free(itype);
return 0; }
static void free_wtype(weapon_type *wtype) {
free(wtype->damage[0]);
free(wtype->damage[1]);
free(wtype);
} }
int free_rtype_cb(const void * match, const void * key, size_t keylen, void *cbdata) { int free_rtype_cb(const void * match, const void * key, size_t keylen, void *cbdata) {
@ -1193,6 +1198,9 @@ int free_rtype_cb(const void * match, const void * key, size_t keylen, void *cbd
if (rtype->itype) { if (rtype->itype) {
free_itype(rtype->itype); free_itype(rtype->itype);
} }
if (rtype->wtype) {
free_wtype(rtype->wtype);
}
free(rtype); free(rtype);
return 0; return 0;
} }

View File

@ -211,7 +211,7 @@ extern "C" {
typedef struct weapon_type { typedef struct weapon_type {
const item_type *itype; const item_type *itype;
const char *damage[2]; char *damage[2];
unsigned int flags; unsigned int flags;
skill_t skill; skill_t skill;
int minskill; int minskill;