diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-02-26 07:49:07 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-02-26 07:49:07 +0800 |
commit | c0341b44ef5512036249fc21987b1751e81419c5 (patch) | |
tree | bad2574f40a3e736025f603f479030ae02c570fb | |
parent | b1d550d1029d14abe5655aa69fa9b4afd52df65a (diff) | |
download | pttbbs-c0341b44ef5512036249fc21987b1751e81419c5.tar pttbbs-c0341b44ef5512036249fc21987b1751e81419c5.tar.gz pttbbs-c0341b44ef5512036249fc21987b1751e81419c5.tar.bz2 pttbbs-c0341b44ef5512036249fc21987b1751e81419c5.tar.lz pttbbs-c0341b44ef5512036249fc21987b1751e81419c5.tar.xz pttbbs-c0341b44ef5512036249fc21987b1751e81419c5.tar.zst pttbbs-c0341b44ef5512036249fc21987b1751e81419c5.zip |
reduce some hundred of system call for each logout
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2553 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | mbbsd/fav.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/mbbsd/fav.c b/mbbsd/fav.c index 9c534922..57292d19 100644 --- a/mbbsd/fav.c +++ b/mbbsd/fav.c @@ -511,7 +511,7 @@ int fav_load(void) } /* write to the rec file */ -static void write_favrec(int fd, fav_t *fp) +static void write_favrec(FILE *fwp, fav_t *fp) { int i; fav_type_t *ft; @@ -519,31 +519,31 @@ static void write_favrec(int fd, fav_t *fp) if (fp == NULL) return; - write(fd, &fp->nBoards, sizeof(fp->nBoards)); - write(fd, &fp->nLines, sizeof(fp->nLines)); - write(fd, &fp->nFolders, sizeof(fp->nFolders)); + fwrite(&fp->nBoards, sizeof(fp->nBoards), 1, fwp); + fwrite(&fp->nLines, sizeof(fp->nLines), 1, fwp); + fwrite(&fp->nFolders, sizeof(fp->nFolders), 1, fwp); fp->DataTail = get_data_number(fp); for(i = 0; i < fp->DataTail; i++){ ft = &fp->favh[i]; - write(fd, &ft->type, sizeof(ft->type)); - write(fd, &ft->attr, sizeof(ft->attr)); + fwrite(&ft->type, sizeof(ft->type), 1, fwp); + fwrite(&ft->attr, sizeof(ft->attr), 1, fwp); /* TODO Please refer to read_favrec() */ switch (ft->type) { case FAVT_FOLDER: - write(fd, ft->fp, sizeof(fav_folder4_t)); + fwrite(ft->fp, sizeof(fav_folder4_t), 1, fwp); break; case FAVT_BOARD: case FAVT_LINE: - write(fd, ft->fp, get_type_size(ft->type)); + fwrite(ft->fp, get_type_size(ft->type), 1, fwp); break; } } for(i = 0; i < fp->DataTail; i++){ if (fp->favh[i].type == FAVT_FOLDER) - write_favrec(fd, get_fav_folder(&fp->favh[i])); + write_favrec(fwp, get_fav_folder(&fp->favh[i])); } } @@ -553,7 +553,7 @@ static void write_favrec(int fd, fav_t *fp) */ int fav_save(void) { - int fd; + FILE *fwp; char buf[64], buf2[64]; fav_t *fp = get_fav_root(); #ifdef MEM_CHECK @@ -565,11 +565,11 @@ int fav_save(void) fav_cleanup(); setuserfile(buf, FAV4".tmp"); setuserfile(buf2, FAV4); - fd = open(buf, O_CREAT | O_WRONLY, 0600); - if (fd < 0) + fwp = fopen(buf, "w"); + if(fwp == NULL) return -1; - write_favrec(fd, fp); - close(fd); + write_favrec(fwp, fp); + fclose(fwp); Rename(buf, buf2); return 0; |