From 8d4ea289db478f23708c0338e043467c0ad65eee Mon Sep 17 00:00:00 2001 From: kcwu Date: Mon, 1 Nov 2004 14:53:21 +0000 Subject: use memmove instead of memcpy if overlapping git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2303 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/read.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'mbbsd/read.c') diff --git a/mbbsd/read.c b/mbbsd/read.c index a54aa614..5350277d 100644 --- a/mbbsd/read.c +++ b/mbbsd/read.c @@ -18,7 +18,7 @@ UnTagger(int locus) TagNum--; if (TagNum > locus) - memcpy(&TagList[locus], &TagList[locus + 1], + memmove(&TagList[locus], &TagList[locus + 1], (TagNum - locus) * sizeof(TagItem)); } @@ -50,11 +50,12 @@ Tagger(time_t chrono, int recno, int mode) return NA; TagNum--; - memcpy(&TagList[posi], &TagList[posi + 1], + memmove(&TagList[posi], &TagList[posi + 1], (TagNum - posi) * sizeof(TagItem)); } else if (TagNum < MAXTAGS) { TagItem *tagp, buf[MAXTAGS]; + /* TODO memmove 即可, 不用另開 buf[] 再 memcpy 兩次 */ tail = (TagNum - head) * sizeof(TagItem); tagp = &TagList[head]; memcpy(buf, tagp, tail); @@ -194,6 +195,7 @@ getkeep(char *s, int def_topline, int def_cursline) { static struct keeploc_t *keeplist = NULL; struct keeploc_t *p; + /* TODO board 存 bid, 其他存 hash, 不要 strdup */ if (def_cursline >= 0) for (p = keeplist; p; p = p->next) { -- cgit v1.2.3