summaryrefslogtreecommitdiffstats
path: root/mbbsd/board.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-04-15 17:31:46 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-04-15 17:31:46 +0800
commit8b76c42baf925d78e076f3539d95481804927db6 (patch)
tree2f03dcc72b15403bf2f0eeafb380c0a75b61f997 /mbbsd/board.c
parent52fcd2ecfd123a83c95c99550ca8ee0b1a0e9228 (diff)
downloadpttbbs-8b76c42baf925d78e076f3539d95481804927db6.tar
pttbbs-8b76c42baf925d78e076f3539d95481804927db6.tar.gz
pttbbs-8b76c42baf925d78e076f3539d95481804927db6.tar.bz2
pttbbs-8b76c42baf925d78e076f3539d95481804927db6.tar.lz
pttbbs-8b76c42baf925d78e076f3539d95481804927db6.tar.xz
pttbbs-8b76c42baf925d78e076f3539d95481804927db6.tar.zst
pttbbs-8b76c42baf925d78e076f3539d95481804927db6.zip
revert to 1.123
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@797 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/board.c')
-rw-r--r--mbbsd/board.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/mbbsd/board.c b/mbbsd/board.c
index ccd208b9..131c9e8e 100644
--- a/mbbsd/board.c
+++ b/mbbsd/board.c
@@ -1,4 +1,4 @@
-/* $Id: board.c,v 1.124 2003/04/15 06:07:23 in2 Exp $ */
+/* $Id: board.c,v 1.125 2003/04/15 09:31:46 in2 Exp $ */
#include "bbs.h"
#define BRC_STRLEN 15 /* Length of board name */
#define BRC_MAXSIZE 24576
@@ -718,9 +718,7 @@ load_boards(char *key)
int type = cuser.uflag & BRDSORT_FLAG ? 1 : 0;
int i, n;
int state;
-#ifdef CRITICAL_MEMORY
- boardstat_t *tmpnbrd;
-#endif
+ char byMALLOC = 0, needREALLOC = 0;
if (class_bid > 0) {
bptr = &bcache[class_bid - 1];
@@ -733,8 +731,8 @@ load_boards(char *key)
nbrd = NULL;
}
if (class_bid <= 0) {
- nbrd = (boardstat_t *) MALLOC(sizeof(boardstat_t) * numboards);
if( yank_flag == 0 ){ // fav mode
+ nbrd = (boardstat_t *)malloc(sizeof(boardstat_t) * fav->nDatas);
for( i = 0 ; i < fav->nDatas ; ++i ){
if( fav->b[i].attr & BRD_FAV ){
if( fav->b[i].attr & BRD_LINE )
@@ -746,8 +744,11 @@ load_boards(char *key)
}
}
}
+ byMALLOC = 0;
+ needREALLOC = (fav->nDatas != brdnum);
}
else{ // general case
+ nbrd = (boardstat_t *) MALLOC(sizeof(boardstat_t) * numboards);
for (i = 0; i < numboards; i++) {
if ((bptr = SHM->bsorted[type][i]) == NULL)
continue;
@@ -760,12 +761,19 @@ load_boards(char *key)
continue;
addnewbrdstat(n, state);
}
+#ifdef CRITICAL_MEMORY
+ byMALLOC = 1;
+#else
+ byMALLOC = 0;
+#endif
+ needREALLOC = 1;
}
if (class_bid == -1)
qsort(nbrd, brdnum, sizeof(boardstat_t), cmpboardfriends);
} else {
- nbrd = (boardstat_t *) MALLOC(bptr->childcount * sizeof(boardstat_t));
+ int childcount = bptr->childcount;
+ nbrd = (boardstat_t *) malloc(childcount * sizeof(boardstat_t));
for (bptr = bptr->firstchild[type]; bptr != (boardheader_t *) ~ 0;
bptr = bptr->next[type]) {
n = (int)(bptr - bcache);
@@ -775,15 +783,22 @@ load_boards(char *key)
continue;
addnewbrdstat(n, state);
}
+ byMALLOC = 0;
+ needREALLOC = (childcount != brdnum);
+ }
+
+ if( needREALLOC ){
+ if( byMALLOC ){
+ boardstat_t *newnbrd;
+ newnbrd = (boardstat_t *)malloc(sizeof(boardstat_t) * brdnum);
+ memcpy(newnbrd, nbrd, sizeof(boardstat_t) * brdnum);
+ FREE(nbrd);
+ nbrd = newnbrd;
+ }
+ else {
+ nbrd = (boardstat_t *)realloc(nbrd, sizeof(boardstat_t) * brdnum);
+ }
}
-#ifndef CRITICAL_MEMORY
- nbrd = realloc(nbrd, sizeof(boardstat_t) * brdnum);
-#else
- tmpnbrd = (boardstat_t *) malloc(sizeof(boardstat_t) * brdnum);
- memcpy(tmpnbrd, nbrd, sizeof(boardstat_t) * brdnum);
- FREE(nbrd);
- nbrd = tmpnbrd;
-#endif
}
static int