From 073cb050ba1be5e0fb9ce5bab8cfd79dbaea65f9 Mon Sep 17 00:00:00 2001 From: victor Date: Sun, 20 Feb 2005 06:12:29 +0000 Subject: add mallopt option reduce two static array git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2524 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/mbbsd.c | 32 ++++++++++++++++++++++++++++---- mbbsd/stuff.c | 17 ++++++++--------- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 262913f4..6f7125d3 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -1,6 +1,15 @@ /* $Id$ */ #include "bbs.h" +#ifdef __linux__ +# ifdef CRITICAL_MEMORY +# include +# endif +# ifdef DEBUG +# include +# endif +#endif + #define SOCKET_QLEN 4 #define TH_LOW 100 @@ -9,6 +18,13 @@ static void do_aloha(char *hello); static void getremotename(struct sockaddr_in * from, char *rhost, char *rname); +#ifdef CONVERT +void big2gb_init(void*); +void gb2big_init(void*); +void big2uni_init(void*); +void uni2big_init(void*); +#endif + #if 0 static jmp_buf byebye; #endif @@ -1289,6 +1305,18 @@ main(int argc, char *argv[], char *envp[]) Signal(SIGUSR1, SIG_IGN); Signal(SIGUSR2, SIG_IGN); +#if defined(__linux__) && defined(CRITICAL_MEMORY) + #define MY__MMAP_THRESHOLD (1024 * 8) + #define MY__MMAP_MAX (0) + #define MY__TRIM_THRESHOLD (1024 * 8) + #define MY__TOP_PAD (0) + + mallopt (M_MMAP_THRESHOLD, MY__MMAP_THRESHOLD); + mallopt (M_MMAP_MAX, MY__MMAP_MAX); + mallopt (M_TRIM_THRESHOLD, MY__TRIM_THRESHOLD); + mallopt (M_TOP_PAD, MY__TOP_PAD); +#endif + attach_SHM(); if( (argc == 3 && shell_login(argc, argv, envp)) || (argc != 3 && daemon_login(argc, argv, envp)) ) @@ -1376,10 +1404,6 @@ daemon_login(int argc, char *argv[], char *envp[]) /* It's better to do something before fork */ #ifdef CONVERT - void big2gb_init(void*); - void gb2big_init(void*); - void big2uni_init(void*); - void uni2big_init(void*); big2gb_init(NULL); gb2big_init(NULL); big2uni_init(NULL); diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c index c9f31e7d..d3de395a 100644 --- a/mbbsd/stuff.c +++ b/mbbsd/stuff.c @@ -8,6 +8,8 @@ const static char *str_home_file = "home/%c/%s/%s"; const static char *str_board_file = "boards/%c/%s/%s"; const static char *str_board_n_file = "boards/%c/%s/%s.%d"; +static char cdate_buffer[32]; + #define STR_DOTDIR ".DIR" const static char *str_dotdir = STR_DOTDIR; @@ -492,34 +494,31 @@ gettime(int line, time4_t dt, char*head) char * Cdate(time4_t *clock) { - static char foo[32]; time_t temp = (time_t)*clock; struct tm *mytm = localtime(&temp); - strftime(foo, 32, "%m/%d/%Y %T %a", mytm); - return foo; + strftime(cdate_buffer, sizeof(cdate_buffer), "%m/%d/%Y %T %a", mytm); + return cdate_buffer; } char * Cdatelite(time4_t *clock) { - static char foo[32]; time_t temp = (time_t)*clock; struct tm *mytm = localtime(&temp); - strftime(foo, 32, "%m/%d/%Y %T", mytm); - return foo; + strftime(cdate_buffer, sizeof(cdate_buffer), "%m/%d/%Y %T", mytm); + return cdate_buffer; } char * Cdatedate(time4_t * clock) { - static char foo[32]; time_t temp = (time_t)*clock; struct tm *mytm = localtime(&temp); - strftime(foo, 32, "%m/%d/%Y", mytm); - return foo; + strftime(cdate_buffer, sizeof(cdate_buffer), "%m/%d/%Y", mytm); + return cdate_buffer; } #ifndef _BBS_UTIL_C_ -- cgit v1.2.3