du(1): replace malloc + memset with calloc.
This commit is contained in:
parent
ee52391ebe
commit
8c5a59ee44
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=278921
@ -376,7 +376,7 @@ linkchk(FTSENT *p)
|
|||||||
/* If the hash table is getting too full, enlarge it. */
|
/* If the hash table is getting too full, enlarge it. */
|
||||||
if (number_entries > number_buckets * 10 && !stop_allocating) {
|
if (number_entries > number_buckets * 10 && !stop_allocating) {
|
||||||
new_size = number_buckets * 2;
|
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. */
|
/* Try releasing the free list to see if that helps. */
|
||||||
if (new_buckets == NULL && free_list != NULL) {
|
if (new_buckets == NULL && free_list != NULL) {
|
||||||
@ -385,16 +385,13 @@ linkchk(FTSENT *p)
|
|||||||
free_list = le->next;
|
free_list = le->next;
|
||||||
free(le);
|
free(le);
|
||||||
}
|
}
|
||||||
new_buckets = malloc(new_size *
|
new_buckets = calloc(new_size, sizeof(new_buckets[0]));
|
||||||
sizeof(new_buckets[0]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_buckets == NULL) {
|
if (new_buckets == NULL) {
|
||||||
stop_allocating = 1;
|
stop_allocating = 1;
|
||||||
warnx("No more memory for tracking hard links");
|
warnx("No more memory for tracking hard links");
|
||||||
} else {
|
} else {
|
||||||
memset(new_buckets, 0,
|
|
||||||
new_size * sizeof(struct links_entry *));
|
|
||||||
for (i = 0; i < number_buckets; i++) {
|
for (i = 0; i < number_buckets; i++) {
|
||||||
while (buckets[i] != NULL) {
|
while (buckets[i] != NULL) {
|
||||||
/* Remove entry from old bucket. */
|
/* Remove entry from old bucket. */
|
||||||
|
Loading…
Reference in New Issue
Block a user