From b4acb828d76cfa0a04ad2207bc04c22187b71e90 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 7 May 2005 13:38:46 +0000 Subject: [PATCH] Ein bischen aufraeumen am Schluss kann nicht wehtun. Nicht doll. --- src/Jamrules | 8 +++++++- src/common/kernel/message.c | 13 +++++++++++++ src/common/kernel/message.h | 17 +++++++++-------- src/common/kernel/region.c | 30 ++++++++++++++++++++++++------ src/eressea/server.cpp | 12 ------------ 5 files changed, 53 insertions(+), 27 deletions(-) diff --git a/src/Jamrules b/src/Jamrules index 05ea25c35..b46ac35f0 100644 --- a/src/Jamrules +++ b/src/Jamrules @@ -8,7 +8,12 @@ if ! $(HAVE_LUA) { } if ! $(DISTCC_HOSTS) { -} else { +} +else { + DISTCC = 1 ; +} + +if $(DISTCC) { CC = distcc $(CC) ; C++ = distcc $(C++) ; Echo Compiling with distcc ; @@ -24,6 +29,7 @@ if ! $(CCACHE_DIR) { if $(DMALLOC) { Echo Compiling with dmalloc ; CCFLAGS += -DUSE_DMALLOC ; + C++FLAGS += -DUSE_DMALLOC ; LINKFLAGS += -ldmalloc ; } diff --git a/src/common/kernel/message.c b/src/common/kernel/message.c index 58708c7f7..3223fbd9f 100644 --- a/src/common/kernel/message.c +++ b/src/common/kernel/message.c @@ -350,6 +350,19 @@ cmistake(const unit * u, struct order *ord, int mno, int mtype) extern unsigned int new_hashstring(const char* s); +void +free_messagelist(message_list * msgs) +{ + struct mlist ** mlistptr = &msgs->begin; + while (*mlistptr) { + struct mlist * ml = *mlistptr; + *mlistptr = ml->next; + msg_release(ml->msg); + free(ml); + } + free(msgs); +} + message * add_message(message_list** pm, message * m) { diff --git a/src/common/kernel/message.h b/src/common/kernel/message.h index fcaab8add..64780e7f0 100644 --- a/src/common/kernel/message.h +++ b/src/common/kernel/message.h @@ -28,16 +28,17 @@ struct msglevel; struct message_type; typedef struct message_list { - struct mlist { - struct mlist * next; - struct message *msg; - } * begin, **end; + struct mlist { + struct mlist * next; + struct message *msg; + } * begin, **end; } message_list; -typedef struct messageclass -{ - struct messageclass * next; - const char * name; +extern void free_messagelist(message_list * msgs); + +typedef struct messageclass { + struct messageclass * next; + const char * name; } messageclass; typedef struct msglevel { diff --git a/src/common/kernel/region.c b/src/common/kernel/region.c index 944cc8033..2374a7cf6 100644 --- a/src/common/kernel/region.c +++ b/src/common/kernel/region.c @@ -797,12 +797,30 @@ freeland(land_region * lr) void free_region(region * r) { - runhash(r); - if (last == r) last = NULL; - free(r->display); - if (r->land) freeland(r->land); - while (r->attribs) a_remove (&r->attribs, r->attribs); - free(r); + runhash(r); + if (last == r) last = NULL; + free(r->display); + if (r->land) freeland(r->land); + + if (r->msgs) { + free_messagelist(r->msgs); + r->msgs = 0; + } + + while (r->individual_messages) { + struct individual_message * msg = r->individual_messages; + r->individual_messages = msg->next; + free_messagelist(msg->msgs); + free(msg); + } + + while (r->attribs) a_remove (&r->attribs, r->attribs); + while (r->resources) { + rawmaterial * res = r->resources; + r->resources = res->next; + free(res); + } + free(r); } static char * diff --git a/src/eressea/server.cpp b/src/eressea/server.cpp index 3b48af623..365de0468 100644 --- a/src/eressea/server.cpp +++ b/src/eressea/server.cpp @@ -414,18 +414,6 @@ game_done(void) region *r = regions; regions = r->next; - if (r->msgs) { - message_list::mlist ** mlistptr = &r->msgs->begin; - while (*mlistptr) { - message_list::mlist * ml = *mlistptr; - *mlistptr = ml->next; - msg_release(ml->msg); - free(ml); - } - free(r->msgs); - r->msgs = 0; - } - while (r->units) { unit * u = r->units; r->units = u->next;