From f2650f5fce0362df7e48c10830e5258c9778502a Mon Sep 17 00:00:00 2001 From: kcwu Date: Tue, 16 Oct 2007 17:08:50 +0000 Subject: * save memory, NameList is more like STL's vector now * fix corner case of fav bug * code revise git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3585 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- include/osdep.h | 5 ----- include/proto.h | 1 + mbbsd/board.c | 4 +++- mbbsd/edit.c | 3 +++ mbbsd/fav.c | 1 + mbbsd/name.c | 6 +++--- mbbsd/talk.c | 4 ++-- 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/include/osdep.h b/include/osdep.h index 117574c5..1fc6ebff 100644 --- a/include/osdep.h +++ b/include/osdep.h @@ -12,15 +12,10 @@ #include - #define _XOPEN_SOURCE - #define _ISOC99_SOURCE - #define HAVE_SETPROCTITLE #elif defined(__linux__) - #define _GNU_SOURCE - #include #include /* for flock() */ #include /* for strcasecmp() */ diff --git a/include/proto.h b/include/proto.h index 0c990e82..8dc9e27f 100644 --- a/include/proto.h +++ b/include/proto.h @@ -417,6 +417,7 @@ typedef char* (*gnc_getname_func)(int); extern void NameList_init(struct NameList *self); extern void NameList_delete(struct NameList *self); extern void NameList_clear(struct NameList *self); +extern void NameList_resizefor(struct NameList *self, int size); extern void NameList_add(struct NameList *self, const char *name); extern void namecomplete2(struct NameList *namelist, const char *prompt, char *data); diff --git a/mbbsd/board.c b/mbbsd/board.c index 1aedfd6f..90482d17 100644 --- a/mbbsd/board.c +++ b/mbbsd/board.c @@ -353,6 +353,8 @@ load_boards(char *key) state |= NBRD_TAG; if (is_set_attr(&fav->favh[i], FAVH_ADM_TAG)) state |= NBRD_TAG; + if (fav_getid(&fav->favh[i]) < 1) + continue; addnewbrdstat(fav_getid(&fav->favh[i]) - 1, NBRD_FAV | state); } } @@ -441,7 +443,6 @@ load_boards(char *key) } if(childcount < brdnum) { //Ptt: dirty fix fix soon - fprintf(stderr, "childcount < brdnum, %d<%d, class_bid=%d\n",childcount,brdnum,class_bid); getbcache(class_bid)->childcount = 0; } @@ -460,6 +461,7 @@ search_board(void) clrtoeol(); NameList_init(&namelist); assert(brdnum<=nbrdsize); + NameList_resizefor(&namelist, brdnum); for (num = 0; num < brdnum; num++) if (!IS_LISTING_FAV() || (nbrd[num].myattr & NBRD_BOARD && HasBoardPerm(B_BH(&nbrd[num]))) ) diff --git a/mbbsd/edit.c b/mbbsd/edit.c index e46f72e5..afbdbf56 100644 --- a/mbbsd/edit.c +++ b/mbbsd/edit.c @@ -1589,6 +1589,9 @@ write_file(char *fpath, int saveheader, int *islocal, char *mytitle) "(R/W/D)讀寫刪暫存檔?"; getdata(1, 0, msg, ans, 2, LCECHO); + // avoid lots pots + sleep(1); + switch (ans[0]) { case 'a': outs("文章" ANSI_COLOR(1) " 沒有 " ANSI_RESET "存入"); diff --git a/mbbsd/fav.c b/mbbsd/fav.c index f7ef9fac..e28ddf0d 100644 --- a/mbbsd/fav.c +++ b/mbbsd/fav.c @@ -542,6 +542,7 @@ int fav_load(void) #endif { fp = (fav_t *)fav_malloc(sizeof(fav_t)); + fav_number = 0; fav_stack_push_fav(fp); } return 0; diff --git a/mbbsd/name.c b/mbbsd/name.c index c136e9a0..f427378e 100644 --- a/mbbsd/name.c +++ b/mbbsd/name.c @@ -31,7 +31,7 @@ void NameList_clear(struct NameList *self) NameList_init(self); } -static void NameList_resizefor(struct NameList *self, int size) +void NameList_resizefor(struct NameList *self, int size) { int capacity = size * (IDLEN+1); #define MIN_CAPACITY 4096 @@ -44,8 +44,8 @@ static void NameList_resizefor(struct NameList *self, int size) assert(capacity > 0); if (self->capacity == 0) self->capacity = MIN_CAPACITY; - if (self->capacity > capacity && self->capacity > MIN_CAPACITY) - self->capacity /= 2; + //if (self->capacity > capacity && self->capacity > MIN_CAPACITY) + // self->capacity /= 2; if (self->capacity < capacity) self->capacity *= 2; diff --git a/mbbsd/talk.c b/mbbsd/talk.c index 94186dbf..50be465c 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -3112,11 +3112,11 @@ establish_talk_connection(const userinfo_t *uip) sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); sin.sin_port = uip->sockaddr; if ((a = socket(sin.sin_family, SOCK_STREAM, 0)) < 0) { - perror("connect err"); + perror("socket err"); return -1; } if ((connect(a, (struct sockaddr *) & sin, sizeof(sin)))) { - perror("connect err"); + //perror("connect err"); return -1; } return a; -- cgit v1.2.3