Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 May 2009 23:00:20 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r192570 - head/usr.sbin/iostat
Message-ID:  <200905212300.n4LN0KWR087011@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Thu May 21 23:00:20 2009
New Revision: 192570
URL: http://svn.freebsd.org/changeset/base/192570

Log:
  Use calloc().

Modified:
  head/usr.sbin/iostat/iostat.c

Modified: head/usr.sbin/iostat/iostat.c
==============================================================================
--- head/usr.sbin/iostat/iostat.c	Thu May 21 22:12:42 2009	(r192569)
+++ head/usr.sbin/iostat/iostat.c	Thu May 21 23:00:20 2009	(r192570)
@@ -311,16 +311,13 @@ main(int argc, char **argv)
 		}
 	}
 
-	cur.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo));
+	cur.dinfo = (struct devinfo *)calloc(1, sizeof(struct devinfo));
 	if (cur.dinfo == NULL)
-		err(1, "malloc failed");
+		err(1, "calloc failed");
 
-	last.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo));
+	last.dinfo = (struct devinfo *)calloc(1, sizeof(struct devinfo));
 	if (last.dinfo == NULL)
-		err(1, "malloc failed");
-
-	bzero(cur.dinfo, sizeof(struct devinfo));
-	bzero(last.dinfo, sizeof(struct devinfo));
+		err(1, "calloc failed");
 
 	/*
 	 * Grab all the devices.  We don't look to see if the list has



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905212300.n4LN0KWR087011>