From 33b8fd47955eeab26cede233b14d683b8e0491b8 Mon Sep 17 00:00:00 2001 From: celest Date: Wed, 23 Mar 2005 15:26:52 +0000 Subject: * Fixed alot of memory leaks * Added stray memory cleaning routine to db.c git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1275 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/core.c | 12 ++++++------ src/common/malloc.c | 4 +--- src/common/malloc.h | 3 +++ src/common/socket.c | 8 +++----- src/common/timer.h | 4 +--- 5 files changed, 14 insertions(+), 17 deletions(-) (limited to 'src/common') diff --git a/src/common/core.c b/src/common/core.c index 96d2c872b..03945040a 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -285,6 +285,12 @@ int main(int argc,char **argv) { int next; + display_title(); +#ifdef USE_MEMMGR + // call this first so it'll be finalised last + do_init_memmgr(argv[0]); // 一番最初に実行する必要がある +#endif + sscanf(argv[0], "./%24[^\n]", server_type); // map/char/login? atexit(log_uptime); pid_create(argv[0]); @@ -305,12 +311,6 @@ int main(int argc,char **argv) compat_signal(SIGTRAP, SIG_DFL); #endif - display_title(); - -#ifdef USE_MEMMGR - do_init_memmgr(argv[0]); // 一番最初に実行する必要がある -#endif - tick_ = time(0); ticks = gettick(); diff --git a/src/common/malloc.c b/src/common/malloc.c index 40c9f34bf..703933d01 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -7,9 +7,6 @@ #include "memwatch.h" #endif -// 独自メモリマネージャを使用する場合、次のコメントを外してください。 -// #define USE_MEMMGR - #if !defined(DMALLOC) && !defined(GCOLLECT) && !defined(BCHECK) && !defined(USE_MEMMGR) void* aMalloc_( size_t size, const char *file, int line, const char *func ) @@ -537,6 +534,7 @@ static void memmer_exit(void) { printf("memmgr: no memory leaks found.\n"); } else { printf("memmgr: memory leaks found.\n"); + fclose(fp); } } diff --git a/src/common/malloc.h b/src/common/malloc.h index 45451c9e0..eec138cdd 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -3,6 +3,9 @@ #include +// 独自メモリマネージャを使用する場合、次のコメントを外してください。 +// #define USE_MEMMGR + #if defined(DMALLOC) # include "dmalloc.h" diff --git a/src/common/socket.c b/src/common/socket.c index f49d4c0ca..1c4d5931a 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -943,11 +943,9 @@ void do_final_socket(void) aFree(access_deny); // session[0] のダミーデータを削除 - if (session[0]) { - aFree(session[0]->rdata); - aFree(session[0]->wdata); - aFree(session[0]); - } + aFree(session[0]->rdata); + aFree(session[0]->wdata); + aFree(session[0]); } void do_socket(void) diff --git a/src/common/timer.h b/src/common/timer.h index c43c0e6b0..57036ae01 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -36,11 +36,9 @@ int addtick_timer(int tid,unsigned int tick); struct TimerData *get_timer(int tid); int do_timer(unsigned int tick); +void timer_final(); int add_timer_func_list(int (*)(int,unsigned int,int,int),char*); -void do_final_timer(void); char* search_timer_func_list(int (*)(int,unsigned int,int,int)); -extern void timer_final(); - #endif // _TIMER_H_ -- cgit v1.2.3-70-g09d2