forked from github/server
fix some memory leaks
- t_free does not free - free_factions frees the wrong list - cleanup after attrib test
This commit is contained in:
parent
d43265f937
commit
7e98384542
|
@ -342,7 +342,7 @@ static faction *dead_factions;
|
||||||
|
|
||||||
void free_flist(faction **fp) {
|
void free_flist(faction **fp) {
|
||||||
faction * flist = *fp;
|
faction * flist = *fp;
|
||||||
for (flist = factions; flist;) {
|
while (flist) {
|
||||||
faction *f = flist;
|
faction *f = flist;
|
||||||
flist = f->next;
|
flist = f->next;
|
||||||
free_faction(f);
|
free_faction(f);
|
||||||
|
@ -681,8 +681,6 @@ void remove_empty_factions(void)
|
||||||
if (!(f->_alive && f->units!=NULL) && !fval(f, FFL_NOIDLEOUT)) {
|
if (!(f->_alive && f->units!=NULL) && !fval(f, FFL_NOIDLEOUT)) {
|
||||||
log_debug("dead: %s", factionname(f));
|
log_debug("dead: %s", factionname(f));
|
||||||
destroyfaction(fp);
|
destroyfaction(fp);
|
||||||
free_faction(f);
|
|
||||||
free(f);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fp = &(*fp)->next;
|
fp = &(*fp)->next;
|
||||||
|
|
|
@ -49,6 +49,7 @@ static void test_attrib_remove_self(CuTest * tc) {
|
||||||
CuAssertPtrEquals(tc, 0, alist->nexttype);
|
CuAssertPtrEquals(tc, 0, alist->nexttype);
|
||||||
CuAssertIntEquals(tc, 1, a_remove(&alist, alist));
|
CuAssertIntEquals(tc, 1, a_remove(&alist, alist));
|
||||||
CuAssertPtrEquals(tc, a, alist);
|
CuAssertPtrEquals(tc, a, alist);
|
||||||
|
a_removeall(&alist, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ int read_triggers(struct gamedata *data, trigger ** tp)
|
||||||
break;
|
break;
|
||||||
case AT_READ_FAIL:
|
case AT_READ_FAIL:
|
||||||
t_free(*tp);
|
t_free(*tp);
|
||||||
|
free(*tp);
|
||||||
*tp = NULL;
|
*tp = NULL;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -107,6 +108,7 @@ int handle_triggers(trigger ** triggers, void *param)
|
||||||
if (t->type->handle(t, param) != 0) {
|
if (t->type->handle(t, param) != 0) {
|
||||||
*tp = t->next;
|
*tp = t->next;
|
||||||
t_free(t);
|
t_free(t);
|
||||||
|
free(t);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
tp = &t->next;
|
tp = &t->next;
|
||||||
|
@ -260,6 +262,7 @@ const trigger_type * tt)
|
||||||
if (t->type == tt) {
|
if (t->type == tt) {
|
||||||
*tp = t->next;
|
*tp = t->next;
|
||||||
t_free(t);
|
t_free(t);
|
||||||
|
free(t);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
tp = &t->next;
|
tp = &t->next;
|
||||||
|
|
Loading…
Reference in New Issue