diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2006-04-02 21:38:58 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2006-04-02 21:38:58 +0000 |
commit | 5b14fea36497511e6428b2c588513d92bc92cb90 (patch) | |
tree | 0b66759932d131cfb42148e0672334d215e6b99f /sbin/sysctl/sysctl.c | |
parent | ba37f6b6fd488dbe7dd7be429e8b7a994a783155 (diff) |
malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@
Diffstat (limited to 'sbin/sysctl/sysctl.c')
-rw-r--r-- | sbin/sysctl/sysctl.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index bb6844c5d77..bd28936e982 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.c,v 1.133 2005/11/30 15:46:32 dlg Exp $ */ +/* $OpenBSD: sysctl.c,v 1.134 2006/04/02 21:38:56 djm Exp $ */ /* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */ /* @@ -40,7 +40,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)sysctl.c 8.5 (Berkeley) 5/9/95"; #else -static const char rcsid[] = "$OpenBSD: sysctl.c,v 1.133 2005/11/30 15:46:32 dlg Exp $"; +static const char rcsid[] = "$OpenBSD: sysctl.c,v 1.134 2006/04/02 21:38:56 djm Exp $"; #endif #endif /* not lint */ @@ -1146,20 +1146,17 @@ vfsinit(void) if (sysctl(mib, 3, &maxtypenum, &buflen, (void *)0, (size_t)0) < 0) return; maxtypenum++; /* + generic */ - if ((vfs_typenums = malloc(maxtypenum * sizeof(int))) == NULL) + if ((vfs_typenums = calloc(maxtypenum, sizeof(int))) == NULL) return; - memset(vfs_typenums, 0, maxtypenum * sizeof(int)); - if ((vfsvars = malloc(maxtypenum * sizeof(*vfsvars))) == NULL) { + if ((vfsvars = calloc(maxtypenum, sizeof(*vfsvars))) == NULL) { free(vfs_typenums); return; } - memset(vfsvars, 0, maxtypenum * sizeof(*vfsvars)); - if ((vfsname = malloc(maxtypenum * sizeof(*vfsname))) == NULL) { + if ((vfsname = calloc(maxtypenum, sizeof(*vfsname))) == NULL) { free(vfs_typenums); free(vfsvars); return; } - memset(vfsname, 0, maxtypenum * sizeof(*vfsname)); mib[2] = VFS_CONF; buflen = sizeof vfc; for (loc = lastused, cnt = 1; cnt < maxtypenum; cnt++) { |