diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2015-02-18 23:16:09 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2015-02-18 23:16:09 +0000 |
commit | d19469a2ddb2a8a47d59890f7b7672590556ec0b (patch) | |
tree | a608a3cb84a854628842f1256ed94ec403e63471 /games | |
parent | af149313a7902e07f9c6fe89b5d7e832dc669005 (diff) |
don't cast function arguments; use reallocarray in one place
Diffstat (limited to 'games')
-rw-r--r-- | games/worms/worms.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/games/worms/worms.c b/games/worms/worms.c index ee78203b0f0..7dda2893a7a 100644 --- a/games/worms/worms.c +++ b/games/worms/worms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: worms.c,v 1.21 2013/08/29 20:22:21 naddy Exp $ */ +/* $OpenBSD: worms.c,v 1.22 2015/02/18 23:16:08 tedu Exp $ */ /* * Copyright (c) 1980, 1993 @@ -226,7 +226,7 @@ main(int argc, char *argv[]) sleeptime.tv_nsec = delay * 500000; timespecadd(&sleeptime, &sleeptime, &sleeptime); - if (!(worm = calloc((size_t)number, sizeof(struct worm)))) + if (!(worm = calloc(number, sizeof(struct worm)))) nomem(); initscr(); curs_set(0); @@ -234,8 +234,8 @@ main(int argc, char *argv[]) LI = LINES; last = CO - 1; bottom = LI - 1; - if (!(ip = malloc((size_t)(LI * CO * sizeof(short)))) || - !(ref = calloc((size_t)LI, sizeof(short *)))) { + if (!(ip = reallocarray(NULL, LI, CO * sizeof(short))) || + !(ref = calloc(LI, sizeof(short *)))) { endwin(); nomem(); } @@ -247,14 +247,14 @@ main(int argc, char *argv[]) *ip++ = 0; for (n = number, w = &worm[0]; --n >= 0; w++) { w->orientation = w->head = 0; - if (!(ip = calloc((size_t)length, sizeof(short)))) { + if (!(ip = calloc(length, sizeof(short)))) { endwin(); nomem(); } w->xpos = ip; for (x = length; --x >= 0;) *ip++ = -1; - if (!(ip = calloc((size_t)length, sizeof(short)))) { + if (!(ip = calloc(length, sizeof(short)))) { endwin(); nomem(); } |