Date: Tue, 17 Feb 2015 21:12:46 +0000 (UTC) From: "Pedro F. Giffuni" <pfg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r278921 - head/usr.bin/du Message-ID: <201502172112.t1HLCk4p041025@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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. */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201502172112.t1HLCk4p041025>