From 3a682078f1139a4bf98bd6c45ebe7c4529c37fe1 Mon Sep 17 00:00:00 2001 From: ptt Date: Wed, 10 Jan 2007 20:54:42 +0000 Subject: fix a bug on stamp file which does unnecessary memset sometimes. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3471 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/bbs.c | 9 ++++----- mbbsd/record.c | 12 ++++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'mbbsd') diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index e984f30c..4dbae34b 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -512,7 +512,7 @@ cancelpost(const fileheader_t *fh, int by_BM, char *newpath) memcpy(&postfile, fh, sizeof(fileheader_t)); setbpath(newpath, brd); - stampfile(newpath, &postfile); + stampfile_u(newpath, &postfile); nick[0] = '\0'; while (fgets(genbuf, sizeof(genbuf), fin)) { @@ -760,7 +760,7 @@ static int do_general(int isbid) { bid_t bidinfo; - fileheader_t postfile, fh; + fileheader_t postfile; char fpath[80], buf[80]; int aborted, defanony, ifuseanony, i; char genbuf[200], *owner; @@ -944,11 +944,10 @@ do_general(int isbid) } strcpy(genbuf, fpath); setbpath(fpath, currboard); - stampfile(fpath, &fh); - strcpy(postfile.filename, fh.filename); + stampfile_u(fpath, &postfile); // Ptt: stamp file again to make it order // fix the bug that search failure in getindex - // + // stampfile_u is used when you don't want to clear other fields if (append_record(buf, &postfile, sizeof(postfile)) == -1) { unlink(genbuf); diff --git a/mbbsd/record.c b/mbbsd/record.c index 0015e7a4..7a2fc429 100644 --- a/mbbsd/record.c +++ b/mbbsd/record.c @@ -463,7 +463,9 @@ apply_record(const char *fpath, int (*fptr) (void *item, void *optarg), int size /* mail / post 時,依據時間建立檔案,加上郵戳 */ int -stampfile(char *fpath, fileheader_t * fh) +stampfile_u(char *fpath, fileheader_t * fh) + // Ptt: stampfile_u: won't clear fileheader + // stampfile: will clear fileheader { register char *ip = fpath; time4_t dtime = COMMON_TIME; @@ -488,7 +490,6 @@ stampfile(char *fpath, fileheader_t * fh) } while ((fp = open(fpath, O_CREAT | O_EXCL | O_WRONLY, 0644)) == -1); close(fp); #endif - memset(fh, 0, sizeof(fileheader_t)); strlcpy(fh->filename, ip, sizeof(fh->filename)); ptime = localtime4(&dtime); snprintf(fh->date, sizeof(fh->date), @@ -496,6 +497,13 @@ stampfile(char *fpath, fileheader_t * fh) return 0; } +inline int +stampfile(char *fpath, fileheader_t * fh) +{ + memset(fh, 0, sizeof(fileheader_t)); + return stampfile_u(fpath, fh); +} + void stampdir(char *fpath, fileheader_t * fh) { -- cgit v1.2.3