diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2007-10-17 01:08:50 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2007-10-17 01:08:50 +0800 |
commit | f2650f5fce0362df7e48c10830e5258c9778502a (patch) | |
tree | 436d5e8909ab6427575b3314673c8b11c255e6c2 | |
parent | 7daae7397382c30de7a7851ffa1ded14969b1f76 (diff) | |
download | pttbbs-f2650f5fce0362df7e48c10830e5258c9778502a.tar pttbbs-f2650f5fce0362df7e48c10830e5258c9778502a.tar.gz pttbbs-f2650f5fce0362df7e48c10830e5258c9778502a.tar.bz2 pttbbs-f2650f5fce0362df7e48c10830e5258c9778502a.tar.lz pttbbs-f2650f5fce0362df7e48c10830e5258c9778502a.tar.xz pttbbs-f2650f5fce0362df7e48c10830e5258c9778502a.tar.zst pttbbs-f2650f5fce0362df7e48c10830e5258c9778502a.zip |
* 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
-rw-r--r-- | include/osdep.h | 5 | ||||
-rw-r--r-- | include/proto.h | 1 | ||||
-rw-r--r-- | mbbsd/board.c | 4 | ||||
-rw-r--r-- | mbbsd/edit.c | 3 | ||||
-rw-r--r-- | mbbsd/fav.c | 1 | ||||
-rw-r--r-- | mbbsd/name.c | 6 | ||||
-rw-r--r-- | 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 <machine/param.h> - #define _XOPEN_SOURCE - #define _ISOC99_SOURCE - #define HAVE_SETPROCTITLE #elif defined(__linux__) - #define _GNU_SOURCE - #include <sys/ioctl.h> #include <sys/file.h> /* for flock() */ #include <strings.h> /* 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; |