From 8cd3845b085ad8eda1bff8abb4cf01bed8691d5c Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 26 Mar 2006 10:16:08 +0000 Subject: [PATCH] Remove useless multiplications with sizeof(char) and sizeof(s_char). Replace by literal 1 in other contexts. --- src/client/termio.c | 2 +- src/lib/commands/navi.c | 2 +- src/lib/commands/path.c | 2 +- src/lib/commands/rea.c | 2 +- src/lib/commands/rout.c | 4 ++-- src/lib/commands/sect.c | 2 +- src/lib/commands/surv.c | 2 +- src/lib/common/maps.c | 2 +- src/lib/subs/radmap.c | 6 ++---- src/lib/subs/satmap.c | 3 +-- src/lib/update/anno.c | 4 ++-- 11 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/client/termio.c b/src/client/termio.c index 8025406d0..a75b080d5 100644 --- a/src/client/termio.c +++ b/src/client/termio.c @@ -164,7 +164,7 @@ termio(int fd, int sock, FILE *auxfi) if (*p == '\n') { if (tagging) { tag = malloc(sizeof(struct tagstruct)); - tag->item = malloc((1 + p - s) * sizeof(char)); + tag->item = malloc(1 + p - s); tag->next = taglist; taglist = tag; t = tag->item; diff --git a/src/lib/commands/navi.c b/src/lib/commands/navi.c index 56a9079a6..154efaab4 100644 --- a/src/lib/commands/navi.c +++ b/src/lib/commands/navi.c @@ -236,7 +236,7 @@ nav_map(int x, int y, int show_designations) if (!snxtsct(&ns, what)) return RET_FAIL; if (!wmapbuf) - wmapbuf = malloc((WORLD_Y * MAPWIDTH(1)) * sizeof(s_char)); + wmapbuf = malloc(WORLD_Y * MAPWIDTH(1)); if (!wmap) { wmap = malloc(WORLD_Y * sizeof(s_char *)); if (wmap && wmapbuf) { diff --git a/src/lib/commands/path.c b/src/lib/commands/path.c index 12ca77566..8ecea9d8a 100644 --- a/src/lib/commands/path.c +++ b/src/lib/commands/path.c @@ -82,7 +82,7 @@ path(void) return RET_FAIL; } if (!mapbuf) - mapbuf = malloc((WORLD_Y * MAPWIDTH(3)) * sizeof(s_char)); + mapbuf = malloc(WORLD_Y * MAPWIDTH(3)); if (!map) { map = malloc(WORLD_Y * sizeof(s_char *)); if (map && mapbuf) { diff --git a/src/lib/commands/rea.c b/src/lib/commands/rea.c index f604e606b..8dcb61b81 100644 --- a/src/lib/commands/rea.c +++ b/src/lib/commands/rea.c @@ -168,7 +168,7 @@ rea(void) nbytes = tgm.tel_length; if (nbytes > sizeof(msgbuf) - 1) nbytes = sizeof(msgbuf) - 1; - (void)fread(msgbuf, sizeof(s_char), nbytes, telfp); + fread(msgbuf, 1, nbytes, telfp); msgbuf[nbytes] = 0; if (readit) uprnf(msgbuf); diff --git a/src/lib/commands/rout.c b/src/lib/commands/rout.c index 4db03efb3..3d9066773 100644 --- a/src/lib/commands/rout.c +++ b/src/lib/commands/rout.c @@ -90,7 +90,7 @@ rout(void) } else if (!snxtsct(&ns, str)) return RET_FAIL; if (!mapbuf) - mapbuf = malloc((WORLD_Y * MAPWIDTH(3)) * sizeof(s_char)); + mapbuf = malloc(WORLD_Y * MAPWIDTH(3)); if (!map) { map = malloc(WORLD_Y * sizeof(s_char *)); if (map && mapbuf) { @@ -102,7 +102,7 @@ rout(void) } } if (!buf) - buf = malloc((MAPWIDTH(3) + 12) * sizeof(s_char)); + buf = malloc(MAPWIDTH(3) + 12); if (!mapbuf || !map || !buf) { pr("Memory error, tell the deity.\n"); logerror("malloc failed in rout\n"); diff --git a/src/lib/commands/sect.c b/src/lib/commands/sect.c index 4058d43b4..7cb7c53b6 100644 --- a/src/lib/commands/sect.c +++ b/src/lib/commands/sect.c @@ -82,7 +82,7 @@ sct(void) } else if (!snxtsct(&ns, str)) return RET_SYN; if (!mapbuf) - mapbuf = malloc((WORLD_Y * MAPWIDTH(1)) * sizeof(s_char)); + mapbuf = malloc(WORLD_Y * MAPWIDTH(1)); if (!map) { map = malloc(WORLD_Y * sizeof(s_char *)); if (map && mapbuf) { diff --git a/src/lib/commands/surv.c b/src/lib/commands/surv.c index 214c86e6a..d3f5ee5fb 100644 --- a/src/lib/commands/surv.c +++ b/src/lib/commands/surv.c @@ -101,7 +101,7 @@ surv(void) } else if (!snxtsct(&nstr, str)) return RET_SYN; if (!mapbuf) - mapbuf = malloc((WORLD_Y * MAPWIDTH(1)) * sizeof(s_char)); + mapbuf = malloc(WORLD_Y * MAPWIDTH(1)); if (!map) { map = malloc(WORLD_Y * sizeof(s_char *)); if (map && mapbuf) { diff --git a/src/lib/common/maps.c b/src/lib/common/maps.c index 558b6b161..f3655e86e 100644 --- a/src/lib/common/maps.c +++ b/src/lib/common/maps.c @@ -71,7 +71,7 @@ draw_map(int bmap, s_char origin, int map_flags, struct nstr_sect *nsp) static s_char **wmap = NULL; if (!wmapbuf) - wmapbuf = malloc((WORLD_Y * MAPWIDTH(1)) * sizeof(s_char)); + wmapbuf = malloc(WORLD_Y * MAPWIDTH(1)); if (!wmap) { wmap = malloc(WORLD_Y * sizeof(s_char *)); if (wmap && wmapbuf) { diff --git a/src/lib/subs/radmap.c b/src/lib/subs/radmap.c index 4af2ba17f..d22fba40b 100644 --- a/src/lib/subs/radmap.c +++ b/src/lib/subs/radmap.c @@ -89,11 +89,9 @@ radmap2(int owner, int changed = 0; if (!radbuf) - radbuf = malloc((WORLD_Y * (WORLD_X + 1)) * - sizeof(s_char)); + radbuf = malloc(WORLD_Y * (WORLD_X + 1)); if (!visbuf) - visbuf = malloc((WORLD_Y * (WORLD_X + 1)) * - sizeof(s_char)); + visbuf = malloc(WORLD_Y * (WORLD_X + 1)); if (!rad) { rad = malloc(WORLD_Y * sizeof(s_char *)); if (rad && radbuf) { diff --git a/src/lib/subs/satmap.c b/src/lib/subs/satmap.c index 316a1468d..14495b835 100644 --- a/src/lib/subs/satmap.c +++ b/src/lib/subs/satmap.c @@ -71,8 +71,7 @@ satmap(int x, int y, int eff, int range, int flags, int type) return; if (!radbuf) - radbuf = malloc((WORLD_Y * (WORLD_X + 1)) * - sizeof(s_char)); + radbuf = malloc(WORLD_Y * (WORLD_X + 1)); if (!rad) { rad = malloc(WORLD_Y * sizeof(s_char *)); if (rad && radbuf) { diff --git a/src/lib/update/anno.c b/src/lib/update/anno.c index a9244fdca..806fdf286 100644 --- a/src/lib/update/anno.c +++ b/src/lib/update/anno.c @@ -147,14 +147,14 @@ copy_and_expire(FILE *annfp, FILE *tmpfp, char *tmp_filename, ++saved; } else ++deleted; - if (fread(message, sizeof(char), tgm.tel_length, annfp) != + if (fread(message, 1, tgm.tel_length, annfp) != (size_t)tgm.tel_length) { logerror("error reading body from telegram file %s", annfil); return 0; } if (writeit) { - if (fwrite(message, sizeof(char), tgm.tel_length, tmpfp) != + if (fwrite(message, 1, tgm.tel_length, tmpfp) != (size_t)tgm.tel_length) { logerror("error writing body to temporary telegram " "file %s", tmp_filename); -- 2.43.0