summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-02-20 14:12:29 +0800
committervictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-02-20 14:12:29 +0800
commit073cb050ba1be5e0fb9ce5bab8cfd79dbaea65f9 (patch)
tree5576d1c39593013b82142378e4be76b685767cf4
parentd3a0349e9b0a732446bd950110629a152afca131 (diff)
downloadpttbbs-073cb050ba1be5e0fb9ce5bab8cfd79dbaea65f9.tar
pttbbs-073cb050ba1be5e0fb9ce5bab8cfd79dbaea65f9.tar.gz
pttbbs-073cb050ba1be5e0fb9ce5bab8cfd79dbaea65f9.tar.bz2
pttbbs-073cb050ba1be5e0fb9ce5bab8cfd79dbaea65f9.tar.lz
pttbbs-073cb050ba1be5e0fb9ce5bab8cfd79dbaea65f9.tar.xz
pttbbs-073cb050ba1be5e0fb9ce5bab8cfd79dbaea65f9.tar.zst
pttbbs-073cb050ba1be5e0fb9ce5bab8cfd79dbaea65f9.zip
add mallopt option
reduce two static array git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2524 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/mbbsd.c32
-rw-r--r--mbbsd/stuff.c17
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 <malloc.h>
+# endif
+# ifdef DEBUG
+# include <mcheck.h>
+# 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_