From owner-svn-src-all@FreeBSD.ORG Tue Feb 17 21:12:46 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9DDEFC3E; Tue, 17 Feb 2015 21:12:46 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 89C4F3E4; Tue, 17 Feb 2015 21:12:46 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1HLCkum041026; Tue, 17 Feb 2015 21:12:46 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1HLCk4p041025; Tue, 17 Feb 2015 21:12:46 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201502172112.t1HLCk4p041025@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Tue, 17 Feb 2015 21:12:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r278921 - head/usr.bin/du X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 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: Tue, 17 Feb 2015 21:12:46 -0000 Author: pfg Date: Tue Feb 17 21:12:45 2015 New Revision: 278921 URL: https://svnweb.freebsd.org/changeset/base/278921 Log: du(1): replace malloc + memset with calloc. Modified: head/usr.bin/du/du.c Modified: head/usr.bin/du/du.c ============================================================================== --- head/usr.bin/du/du.c Tue Feb 17 20:52:51 2015 (r278920) +++ head/usr.bin/du/du.c Tue Feb 17 21:12:45 2015 (r278921) @@ -376,7 +376,7 @@ linkchk(FTSENT *p) /* If the hash table is getting too full, enlarge it. */ if (number_entries > number_buckets * 10 && !stop_allocating) { new_size = number_buckets * 2; - new_buckets = malloc(new_size * sizeof(struct links_entry *)); + new_buckets = calloc(new_size, sizeof(struct links_entry *)); /* Try releasing the free list to see if that helps. */ if (new_buckets == NULL && free_list != NULL) { @@ -385,16 +385,13 @@ linkchk(FTSENT *p) free_list = le->next; free(le); } - new_buckets = malloc(new_size * - sizeof(new_buckets[0])); + new_buckets = calloc(new_size, sizeof(new_buckets[0])); } if (new_buckets == NULL) { stop_allocating = 1; warnx("No more memory for tracking hard links"); } else { - memset(new_buckets, 0, - new_size * sizeof(struct links_entry *)); for (i = 0; i < number_buckets; i++) { while (buckets[i] != NULL) { /* Remove entry from old bucket. */