From 71ee47751a3505ec3c8e6e7621c48d642de9c6de Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 8 May 2005 00:16:32 +0000 Subject: [PATCH] Memory Leaks: - Kampf - Globalreport, Adressen - XPath - at_luxuries --- src/common/gamecode/economy.c | 8 +++++++- src/common/gamecode/report.c | 2 +- src/common/kernel/battle.c | 9 ++++----- src/common/kernel/xmlreader.c | 1 + 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index a3e93d8f3..ed0ad7020 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -1617,8 +1617,14 @@ make_cmd(unit * u, struct order * ord) } /* ------------------------------------------------------------- */ +static void +free_luxuries(struct attrib * a) +{ + i_freeall((item*)a->data.v); +} + const attrib_type at_luxuries = { - "luxuries", NULL, NULL, NULL, NULL, NULL + "luxuries", NULL, free_luxuries, NULL, NULL, NULL }; static void diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index 88bb538cf..15e70e2f9 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -2592,8 +2592,8 @@ global_report(const char * filename) add_seen(seen, r, see_unit, true); } report_computer(F, monsters, seen, addresses, time(NULL)); + freelist(addresses); seen_done(seen); - fclose(F); } diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c index a3d6e9308..06b3478ec 100644 --- a/src/common/kernel/battle.c +++ b/src/common/kernel/battle.c @@ -3228,16 +3228,18 @@ free_battle(battle * b) side *side; fighter *fighter; meffect *meffect; - bfaction * bf; int max_fac_no = 0; if (bdebug) { fclose(bdebug); } - for (bf=b->factions;bf;bf=bf->next) { + while (b->factions) { + bfaction * bf = b->factions; faction * f = bf->faction; + b->factions = bf->next; max_fac_no = max(max_fac_no, f->no); + free(bf); } cv_foreach(side, b->sides) { @@ -3257,9 +3259,6 @@ free_battle(battle * b) } cv_next(meffect); cv_kill(&b->meffects); -/* - cv_kill(&b->factions); -*/ } static int * diff --git a/src/common/kernel/xmlreader.c b/src/common/kernel/xmlreader.c index 759bb2575..c7113b455 100644 --- a/src/common/kernel/xmlreader.c +++ b/src/common/kernel/xmlreader.c @@ -504,6 +504,7 @@ xml_readweapon(xmlXPathContextPtr xpath, item_type * itype) xmlFree(property); } } + xmlXPathFreeObject(races); } xmlXPathFreeObject(result);