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);
} }
rm = rm->next; free(r->msgs);
r->msgs = 0;
} }
#endif
for (u = r->units; u; u = u2) { while (r->units) {
u2 = u->next; unit * u = r->units;
r->units = u->next;
stripunit(u); stripunit(u);
uunhash(u); uunhash(u);
free(u); free(u);
} }
for (b = r->buildings; b; b = b2) {
while (r->buildings) {
building * b = r->buildings;
r->buildings = b->next;
free(b->name); free(b->name);
free(b->display); free(b->display);
b2 = b->next;
free(b); free(b);
} }
for (s = r->ships; s; s = s2) {
while (r->ships) {
ship * s = r->ships;
r->ships = s->next;
free(s->name); free(s->name);
free(s->display); free(s->display);
s2 = s->next;
free(s); free(s);
} }
r2 = r->next;
free_region(r); free_region(r);
} }
for (f = factions; f; f = f2) {
while (factions) {
faction * f = factions;
factions = f->next;
stripfaction(f); stripfaction(f);
f2 = f->next;
free(f); free(f);
} }
while (planes) {
while (planes) {
plane * pl = planes; plane * pl = planes;
planes = planes->next; planes = planes->next;
free(pl); free(pl);
} }
#ifdef LEAK_DETECT
leak_report(stderr); creport_cleanup();
#endif report_cleanup();
creport_cleanup();
report_cleanup();
} }
#endif #endif