summaryrefslogtreecommitdiffstats
path: root/usr.bin/du
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2015-02-17 21:12:45 +0000
committerpfg <pfg@FreeBSD.org>2015-02-17 21:12:45 +0000
commit41e0db3469f44c6718c56f309810cabd095cd873 (patch)
tree810137b093525dfbe866a5b5bc5836cef6a17f63 /usr.bin/du
parent5a69729fb85fb7828b4cfe73a2d55d52af3a60f4 (diff)
downloadFreeBSD-src-41e0db3469f44c6718c56f309810cabd095cd873.zip
FreeBSD-src-41e0db3469f44c6718c56f309810cabd095cd873.tar.gz
du(1): replace malloc + memset with calloc.
Diffstat (limited to 'usr.bin/du')
-rw-r--r--usr.bin/du/du.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/usr.bin/du/du.c b/usr.bin/du/du.c
index 6194a12..506c3f5 100644
--- a/usr.bin/du/du.c
+++ b/usr.bin/du/du.c
@@ -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. */
OpenPOWER on IntegriCloud