Remove useless multiplications with sizeof(char) and sizeof(s_char).

Replace by literal 1 in other contexts.
This commit is contained in:
Markus Armbruster 2006-03-26 10:16:08 +00:00
parent 8ca2468706
commit 8cd3845b08
11 changed files with 14 additions and 17 deletions

View file

@ -164,7 +164,7 @@ termio(int fd, int sock, FILE *auxfi)
if (*p == '\n') { if (*p == '\n') {
if (tagging) { if (tagging) {
tag = malloc(sizeof(struct tagstruct)); tag = malloc(sizeof(struct tagstruct));
tag->item = malloc((1 + p - s) * sizeof(char)); tag->item = malloc(1 + p - s);
tag->next = taglist; tag->next = taglist;
taglist = tag; taglist = tag;
t = tag->item; t = tag->item;

View file

@ -236,7 +236,7 @@ nav_map(int x, int y, int show_designations)
if (!snxtsct(&ns, what)) if (!snxtsct(&ns, what))
return RET_FAIL; return RET_FAIL;
if (!wmapbuf) if (!wmapbuf)
wmapbuf = malloc((WORLD_Y * MAPWIDTH(1)) * sizeof(s_char)); wmapbuf = malloc(WORLD_Y * MAPWIDTH(1));
if (!wmap) { if (!wmap) {
wmap = malloc(WORLD_Y * sizeof(s_char *)); wmap = malloc(WORLD_Y * sizeof(s_char *));
if (wmap && wmapbuf) { if (wmap && wmapbuf) {

View file

@ -82,7 +82,7 @@ path(void)
return RET_FAIL; return RET_FAIL;
} }
if (!mapbuf) if (!mapbuf)
mapbuf = malloc((WORLD_Y * MAPWIDTH(3)) * sizeof(s_char)); mapbuf = malloc(WORLD_Y * MAPWIDTH(3));
if (!map) { if (!map) {
map = malloc(WORLD_Y * sizeof(s_char *)); map = malloc(WORLD_Y * sizeof(s_char *));
if (map && mapbuf) { if (map && mapbuf) {

View file

@ -168,7 +168,7 @@ rea(void)
nbytes = tgm.tel_length; nbytes = tgm.tel_length;
if (nbytes > sizeof(msgbuf) - 1) if (nbytes > sizeof(msgbuf) - 1)
nbytes = sizeof(msgbuf) - 1; nbytes = sizeof(msgbuf) - 1;
(void)fread(msgbuf, sizeof(s_char), nbytes, telfp); fread(msgbuf, 1, nbytes, telfp);
msgbuf[nbytes] = 0; msgbuf[nbytes] = 0;
if (readit) if (readit)
uprnf(msgbuf); uprnf(msgbuf);

View file

@ -90,7 +90,7 @@ rout(void)
} else if (!snxtsct(&ns, str)) } else if (!snxtsct(&ns, str))
return RET_FAIL; return RET_FAIL;
if (!mapbuf) if (!mapbuf)
mapbuf = malloc((WORLD_Y * MAPWIDTH(3)) * sizeof(s_char)); mapbuf = malloc(WORLD_Y * MAPWIDTH(3));
if (!map) { if (!map) {
map = malloc(WORLD_Y * sizeof(s_char *)); map = malloc(WORLD_Y * sizeof(s_char *));
if (map && mapbuf) { if (map && mapbuf) {
@ -102,7 +102,7 @@ rout(void)
} }
} }
if (!buf) if (!buf)
buf = malloc((MAPWIDTH(3) + 12) * sizeof(s_char)); buf = malloc(MAPWIDTH(3) + 12);
if (!mapbuf || !map || !buf) { if (!mapbuf || !map || !buf) {
pr("Memory error, tell the deity.\n"); pr("Memory error, tell the deity.\n");
logerror("malloc failed in rout\n"); logerror("malloc failed in rout\n");

View file

@ -82,7 +82,7 @@ sct(void)
} else if (!snxtsct(&ns, str)) } else if (!snxtsct(&ns, str))
return RET_SYN; return RET_SYN;
if (!mapbuf) if (!mapbuf)
mapbuf = malloc((WORLD_Y * MAPWIDTH(1)) * sizeof(s_char)); mapbuf = malloc(WORLD_Y * MAPWIDTH(1));
if (!map) { if (!map) {
map = malloc(WORLD_Y * sizeof(s_char *)); map = malloc(WORLD_Y * sizeof(s_char *));
if (map && mapbuf) { if (map && mapbuf) {

View file

@ -101,7 +101,7 @@ surv(void)
} else if (!snxtsct(&nstr, str)) } else if (!snxtsct(&nstr, str))
return RET_SYN; return RET_SYN;
if (!mapbuf) if (!mapbuf)
mapbuf = malloc((WORLD_Y * MAPWIDTH(1)) * sizeof(s_char)); mapbuf = malloc(WORLD_Y * MAPWIDTH(1));
if (!map) { if (!map) {
map = malloc(WORLD_Y * sizeof(s_char *)); map = malloc(WORLD_Y * sizeof(s_char *));
if (map && mapbuf) { if (map && mapbuf) {

View file

@ -71,7 +71,7 @@ draw_map(int bmap, s_char origin, int map_flags, struct nstr_sect *nsp)
static s_char **wmap = NULL; static s_char **wmap = NULL;
if (!wmapbuf) if (!wmapbuf)
wmapbuf = malloc((WORLD_Y * MAPWIDTH(1)) * sizeof(s_char)); wmapbuf = malloc(WORLD_Y * MAPWIDTH(1));
if (!wmap) { if (!wmap) {
wmap = malloc(WORLD_Y * sizeof(s_char *)); wmap = malloc(WORLD_Y * sizeof(s_char *));
if (wmap && wmapbuf) { if (wmap && wmapbuf) {

View file

@ -89,11 +89,9 @@ radmap2(int owner,
int changed = 0; int changed = 0;
if (!radbuf) if (!radbuf)
radbuf = malloc((WORLD_Y * (WORLD_X + 1)) * radbuf = malloc(WORLD_Y * (WORLD_X + 1));
sizeof(s_char));
if (!visbuf) if (!visbuf)
visbuf = malloc((WORLD_Y * (WORLD_X + 1)) * visbuf = malloc(WORLD_Y * (WORLD_X + 1));
sizeof(s_char));
if (!rad) { if (!rad) {
rad = malloc(WORLD_Y * sizeof(s_char *)); rad = malloc(WORLD_Y * sizeof(s_char *));
if (rad && radbuf) { if (rad && radbuf) {

View file

@ -71,8 +71,7 @@ satmap(int x, int y, int eff, int range, int flags, int type)
return; return;
if (!radbuf) if (!radbuf)
radbuf = malloc((WORLD_Y * (WORLD_X + 1)) * radbuf = malloc(WORLD_Y * (WORLD_X + 1));
sizeof(s_char));
if (!rad) { if (!rad) {
rad = malloc(WORLD_Y * sizeof(s_char *)); rad = malloc(WORLD_Y * sizeof(s_char *));
if (rad && radbuf) { if (rad && radbuf) {

View file

@ -147,14 +147,14 @@ copy_and_expire(FILE *annfp, FILE *tmpfp, char *tmp_filename,
++saved; ++saved;
} else } else
++deleted; ++deleted;
if (fread(message, sizeof(char), tgm.tel_length, annfp) != if (fread(message, 1, tgm.tel_length, annfp) !=
(size_t)tgm.tel_length) { (size_t)tgm.tel_length) {
logerror("error reading body from telegram file %s", logerror("error reading body from telegram file %s",
annfil); annfil);
return 0; return 0;
} }
if (writeit) { if (writeit) {
if (fwrite(message, sizeof(char), tgm.tel_length, tmpfp) != if (fwrite(message, 1, tgm.tel_length, tmpfp) !=
(size_t)tgm.tel_length) { (size_t)tgm.tel_length) {
logerror("error writing body to temporary telegram " logerror("error writing body to temporary telegram "
"file %s", tmp_filename); "file %s", tmp_filename);