From 6b4ec3825a16382b8aa309a128305b0b09ab520c Mon Sep 17 00:00:00 2001 From: scw Date: Sun, 28 Mar 2004 08:34:25 +0000 Subject: Correcting action about make brc_buf be malloc. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1620 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/bbs.c | 3 +-- mbbsd/board.c | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) (limited to 'mbbsd') diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index 5194d414..3758de88 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -2621,9 +2621,8 @@ Read() #ifdef LOG_BOARD time_t usetime = now; #endif - extern char *brc_buf; - if( !brc_buf ) + if ( ! currboard[0] ) return 0; setutmpmode(READING); diff --git a/mbbsd/board.c b/mbbsd/board.c index dc28ad8d..525cc020 100644 --- a/mbbsd/board.c +++ b/mbbsd/board.c @@ -17,7 +17,7 @@ static time_t brc_expire_time; static int brc_changed = 0; /* The below two will be filled by read_brc_buf() and brc_update() */ -char *brc_buf = NULL; +static char *brc_buf = NULL; static int brc_size; static char * const fn_boardrc = ".boardrc"; @@ -164,6 +164,16 @@ brc_finalize(){ } } +void +brc_initialize(){ + static char done = 0; + if( done ) + return; + done = 1; + brc_expire_time = login_start_time - 365 * 86400; + read_brc_buf(); +} + int brc_read_record(const char* bname, int* num, int* list){ char *ptr; @@ -184,9 +194,12 @@ brc_read_record(const char* bname, int* num, int* list){ int brc_initial_board(const char *boardname) { + brc_initialize(); + if (strcmp(currboard, boardname) == 0) { return brc_num; } + brc_update(); /* write back first */ strlcpy(currboard, boardname, sizeof(currboard)); currbid = getbnum(currboard); @@ -344,12 +357,7 @@ void load_brdbuf(void) void init_brdbuf() { - static char done = 0; - if( done ) - return; - done = 1; - brc_expire_time = login_start_time - 365 * 86400; - read_brc_buf(); + brc_initialize(); brc_initial_board(DEFAULT_BOARD); set_board(); } -- cgit v1.2.3