forked from github/server
fix equipment static memory leak
This commit is contained in:
parent
af310d48d6
commit
dd2f146e27
3 changed files with 15 additions and 0 deletions
|
@ -31,6 +31,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include "building.h"
|
#include "building.h"
|
||||||
#include "calendar.h"
|
#include "calendar.h"
|
||||||
#include "direction.h"
|
#include "direction.h"
|
||||||
|
#include "equipment.h"
|
||||||
#include "faction.h"
|
#include "faction.h"
|
||||||
#include "group.h"
|
#include "group.h"
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
|
@ -1079,6 +1080,7 @@ void free_gamedata(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
free_donations();
|
free_donations();
|
||||||
|
free_equipment();
|
||||||
|
|
||||||
for (i = 0; i != MAXLOCALES; ++i) {
|
for (i = 0; i != MAXLOCALES; ++i) {
|
||||||
if (defaults[i]) {
|
if (defaults[i]) {
|
||||||
|
|
|
@ -223,3 +223,15 @@ void equip_items(struct item **items, const struct equipment *eq)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void free_equipment(void) {
|
||||||
|
equipment **eqp = &equipment_sets;
|
||||||
|
while (*eqp) {
|
||||||
|
equipment *eq = *eqp;
|
||||||
|
*eqp = eq->next;
|
||||||
|
free(eq->name);
|
||||||
|
spellbook_clear(eq->spellbook);
|
||||||
|
// TODO: items, subsets
|
||||||
|
free(eq);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -75,6 +75,7 @@ extern "C" {
|
||||||
int mask);
|
int mask);
|
||||||
void equip_items(struct item **items, const struct equipment *eq);
|
void equip_items(struct item **items, const struct equipment *eq);
|
||||||
|
|
||||||
|
void free_equipment(void);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue