du(1): replace malloc + memset with calloc.
This commit is contained in:
parent
ee52391ebe
commit
8c5a59ee44
@ -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. */
|
||||
|
Loading…
Reference in New Issue
Block a user