summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-05-25 00:21:11 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-05-25 00:21:11 +0800
commit926f38ea9358f13ea09a8311a0171c1c23bbd653 (patch)
tree994400286cd5045586c95bf815d6e197cb5034d4
parente43261562e928585ac73bd333dae548687d451ec (diff)
downloadpttbbs-926f38ea9358f13ea09a8311a0171c1c23bbd653.tar
pttbbs-926f38ea9358f13ea09a8311a0171c1c23bbd653.tar.gz
pttbbs-926f38ea9358f13ea09a8311a0171c1c23bbd653.tar.bz2
pttbbs-926f38ea9358f13ea09a8311a0171c1c23bbd653.tar.lz
pttbbs-926f38ea9358f13ea09a8311a0171c1c23bbd653.tar.xz
pttbbs-926f38ea9358f13ea09a8311a0171c1c23bbd653.tar.zst
pttbbs-926f38ea9358f13ea09a8311a0171c1c23bbd653.zip
dynamic allocation nbrd
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@192 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/board.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/mbbsd/board.c b/mbbsd/board.c
index ec9a44ab..48180836 100644
--- a/mbbsd/board.c
+++ b/mbbsd/board.c
@@ -1,4 +1,4 @@
-/* $Id: board.c,v 1.7 2002/05/24 15:52:33 ptt Exp $ */
+/* $Id: board.c,v 1.8 2002/05/24 16:21:11 ptt Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -230,7 +230,7 @@ typedef struct {
extern time_t login_start_time;
extern int numboards;
static int *zapbuf=NULL,*favbuf;
-static boardstat_t *nbrd;
+static boardstat_t *nbrd=NULL;
#define STR_BBSRC ".bbsrc"
#define STR_FAV ".fav"
@@ -263,8 +263,6 @@ void init_brdbuf() {
close(n);
}
- if(!nbrd)
- nbrd = (boardstat_t *)malloc(MAX_BOARD * sizeof(boardstat_t));
brc_expire_time = login_start_time - 365 * 86400;
}
@@ -438,14 +436,15 @@ static void load_boards(char *key) {
if(class_bid>0)
{
bptr = &bcache[class_bid-1];
- if(bptr->firstchild[type]==NULL)
+ if(bptr->firstchild[type]==NULL || bptr->childcount<=0)
load_uidofgid(class_bid,type);
}
brdnum = 0;
if(class_bid==0)
+ {
+ nbrd = (boardstat_t *)malloc(numboards * sizeof(boardstat_t));
for(i=0 ; i < numboards; i++)
{
-
if( (bptr = brdshm->sorted[type][i]) == NULL )
continue;
n = (int)( bptr - bcache);
@@ -457,8 +456,11 @@ static void load_boards(char *key) {
) continue;
addnewbrdstat(n, state);
}
+ }
else
- for(bptr=bptr->firstchild[type]; bptr!=(boardheader_t *)~0;
+ {
+ nbrd = (boardstat_t *)malloc( bptr->childcount * sizeof(boardstat_t));
+ for(bptr=bptr->firstchild[type]; bptr!=(boardheader_t *)~0;
bptr=bptr->next[type])
{
n = (int)( bptr - bcache);
@@ -468,6 +470,7 @@ static void load_boards(char *key) {
(key[0] && !strcasestr(bptr->title, key))) continue;
addnewbrdstat(n, state);
}
+ }
}
static int search_board() {
@@ -1032,11 +1035,12 @@ static void choose_board(int newflag) {
class_bid = bidtmp;
currutmp->brc_id=tmp;
brdnum = -1;
+ free(nbrd);
}
}
}
} while(ch != 'q');
- save_brdbuf();
+ if(nbrd) free(nbrd);
}
int root_board() {