reactivating some cleanup code

This commit is contained in:
Enno Rehling 2005-05-07 10:31:25 +00:00
parent 264880cc7b
commit d7cf8ccc6a
2 changed files with 58 additions and 58 deletions

View File

@ -298,9 +298,6 @@ processturn(char *filename)
getgarbage(); getgarbage();
puts(" - Nehme Korrekturen am Datenbestand vor"); puts(" - Nehme Korrekturen am Datenbestand vor");
if ((i=readorders(filename))!=0) return i; if ((i=readorders(filename))!=0) return i;
#if BENCHMARK
exit(0);
#endif
if (!nomonsters) { if (!nomonsters) {
if (turn == 0) srand(time((time_t *) NULL)); if (turn == 0) srand(time((time_t *) NULL));
else srand(turn); else srand(turn);
@ -400,9 +397,6 @@ game_done(void)
planes = planes->next; planes = planes->next;
free(pl); free(pl);
} }
#ifdef LEAK_DETECT
leak_report(stderr);
#endif
creport_cleanup(); creport_cleanup();
report_cleanup(); report_cleanup();
} }

View File

@ -104,6 +104,10 @@
#include <ctime> #include <ctime>
#include <clocale> #include <clocale>
#ifdef USE_DMALLOC
# define CLEANUP_CODE
#endif
/** /**
** global variables we are importing from other modules ** global variables we are importing from other modules
**/ **/
@ -386,9 +390,6 @@ process_orders()
puts(" - entferne Texte der letzten Runde"); puts(" - entferne Texte der letzten Runde");
getgarbage(); getgarbage();
puts(" - Nehme Korrekturen am Datenbestand vor"); puts(" - Nehme Korrekturen am Datenbestand vor");
#if BENCHMARK
exit(0);
#endif
processorders(); processorders();
score(); score();
remove_unequipped_guarded(); remove_unequipped_guarded();
@ -406,61 +407,66 @@ game_done(void)
* zum Debugging interessant, wenn man Leak Detection hat, und nach * zum Debugging interessant, wenn man Leak Detection hat, und nach
* nicht freigegebenem Speicher sucht, der nicht bis zum Ende benötigt * nicht freigegebenem Speicher sucht, der nicht bis zum Ende benötigt
* wird (temporäre Hilsstrukturen) */ * wird (temporäre Hilsstrukturen) */
unit *u, *u2;
region *r, *r2;
building *b, *b2;
faction *f, *f2;
ship *s, *s2;
free(used_faction_ids); free(used_faction_ids);
for (r = regions; r; r = r2) {
#if 0 while (regions) {
msg * m = r->msgs; region *r = regions;
while (m) { regions = r->next;
msg * x = m;
m = m->next; if (r->msgs) {
if (x->type->finalize) x->type->finalize(x); message_list::mlist ** mlistptr = &r->msgs->begin;
free(x); while (*mlistptr) {
message_list::mlist * ml = *mlistptr;
*mlistptr = ml->next;
msg_release(ml->msg);
free(ml);
}
free(r->msgs);
r->msgs = 0;
} }
rm = rm->next;
while (r->units) {
unit * u = r->units;
r->units = u->next;
stripunit(u);
uunhash(u);
free(u);
}
while (r->buildings) {
building * b = r->buildings;
r->buildings = b->next;
free(b->name);
free(b->display);
free(b);
}
while (r->ships) {
ship * s = r->ships;
r->ships = s->next;
free(s->name);
free(s->display);
free(s);
}
free_region(r);
} }
#endif
for (u = r->units; u; u = u2) { while (factions) {
u2 = u->next; faction * f = factions;
stripunit(u); factions = f->next;
uunhash(u); stripfaction(f);
free(u); free(f);
} }
for (b = r->buildings; b; b = b2) {
free(b->name); while (planes) {
free(b->display); plane * pl = planes;
b2 = b->next; planes = planes->next;
free(b); free(pl);
} }
for (s = r->ships; s; s = s2) {
free(s->name); creport_cleanup();
free(s->display); report_cleanup();
s2 = s->next;
free(s);
}
r2 = r->next;
free_region(r);
}
for (f = factions; f; f = f2) {
stripfaction(f);
f2 = f->next;
free(f);
}
while (planes) {
plane * pl = planes;
planes = planes->next;
free(pl);
}
#ifdef LEAK_DETECT
leak_report(stderr);
#endif
creport_cleanup();
report_cleanup();
} }
#endif #endif