diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2014-12-01 23:08:24 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2014-12-01 23:08:24 +0000 |
commit | 6360eefedb37c2de6dbef552ae81e858f93ebd3d (patch) | |
tree | 3324c69c495d4d08c9f7afa05140e3df1a63aabc | |
parent | 955a8d67a0947973b8000ca170faf90e75cc6c11 (diff) |
use reallocarray() deep inside an macro ugly as sin
-rw-r--r-- | usr.sbin/user/defs.h | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.sbin/user/defs.h b/usr.sbin/user/defs.h index 4bf2eeada8e..2891fdda929 100644 --- a/usr.sbin/user/defs.h +++ b/usr.sbin/user/defs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: defs.h,v 1.4 2004/04/19 17:48:31 millert Exp $ */ +/* $OpenBSD: defs.h,v 1.5 2014/12/01 23:08:23 deraadt Exp $ */ /* $NetBSD: defs.h,v 1.5 1999/12/24 09:08:49 agc Exp $ */ /* @@ -35,15 +35,19 @@ #define DEFS_H_ #define NEWARRAY(type,ptr,size,action) do { \ - if ((ptr = (type *) calloc(size, sizeof(type))) == (type *) NULL) { \ - warn("can't allocate %ld bytes", (long)(size * sizeof(type))); \ + if ((ptr = (type *) calloc((size), \ + sizeof(type))) == (type *) NULL) { \ + warn("can't allocate %ld bytes", \ + (long)((size) * sizeof(type))); \ action; \ } \ } while( /* CONSTCOND */ 0) #define RENEW(type,ptr,size,action) do { \ - if ((ptr = (type *) realloc(ptr, sizeof(type) * size)) == (type *) NULL) { \ - warn("can't realloc %ld bytes", (long)(size * sizeof(type))); \ + if ((ptr = (type *) reallocarray(ptr, \ + (size), sizeof(type))) == (type *) NULL) { \ + warn("can't realloc %ld bytes", \ + (long)((size) * sizeof(type))); \ action; \ } \ } while( /* CONSTCOND */ 0) |