From owner-svn-src-all@FreeBSD.ORG Fri Oct 17 20:11:28 2008 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9F5631065691; Fri, 17 Oct 2008 20:11:28 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8DE6F8FC1A; Fri, 17 Oct 2008 20:11:28 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id m9HKBSlC096776; Fri, 17 Oct 2008 20:11:28 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9HKBSs7096775; Fri, 17 Oct 2008 20:11:28 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <200810172011.m9HKBSs7096775@svn.freebsd.org> From: Xin LI Date: Fri, 17 Oct 2008 20:11:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r183986 - head/lib/libkvm X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Oct 2008 20:11:28 -0000 Author: delphij Date: Fri Oct 17 20:11:28 2008 New Revision: 183986 URL: http://svn.freebsd.org/changeset/base/183986 Log: Reduce code duplication: use calloc() intead of malloc() and memset afterward. Modified: head/lib/libkvm/kvm.c Modified: head/lib/libkvm/kvm.c ============================================================================== --- head/lib/libkvm/kvm.c Fri Oct 17 20:09:00 2008 (r183985) +++ head/lib/libkvm/kvm.c Fri Oct 17 20:11:28 2008 (r183986) @@ -244,11 +244,10 @@ kvm_openfiles(uf, mf, sf, flag, errout) { kvm_t *kd; - if ((kd = malloc(sizeof(*kd))) == NULL) { + if ((kd = calloc(1, sizeof(*kd))) == NULL) { (void)strlcpy(errout, strerror(errno), _POSIX2_LINE_MAX); return (0); } - memset(kd, 0, sizeof(*kd)); kd->program = 0; return (_kvm_open(kd, uf, mf, flag, errout)); } @@ -263,13 +262,12 @@ kvm_open(uf, mf, sf, flag, errstr) { kvm_t *kd; - if ((kd = malloc(sizeof(*kd))) == NULL) { + if ((kd = calloc(1, sizeof(*kd))) == NULL) { if (errstr != NULL) (void)fprintf(stderr, "%s: %s\n", errstr, strerror(errno)); return (0); } - memset(kd, 0, sizeof(*kd)); kd->program = errstr; return (_kvm_open(kd, uf, mf, flag, NULL)); }