[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 04/17] maint: zalloc → xzalloc
From: |
Eric Blake |
Subject: |
Re: [PATCH 04/17] maint: zalloc → xzalloc |
Date: |
Wed, 12 Jan 2022 14:29:43 -0600 |
User-agent: |
NeoMutt/20211029-182-90c72c |
On Sun, Aug 22, 2021 at 02:02:53PM -0700, Paul Eggert wrote:
> * src/util.c (zalloc): Remove. All uses replaced
> by xzalloc, which means the same thing.
> ---
> src/analyze.c | 8 ++++----
> src/diff.h | 3 ---
> src/io.c | 2 +-
> src/util.c | 10 ----------
> 4 files changed, 5 insertions(+), 18 deletions(-)
>
> diff --git a/src/analyze.c b/src/analyze.c
> index a5e4bdc..e11f7d4 100644
> --- a/src/analyze.c
> +++ b/src/analyze.c
> @@ -67,7 +67,7 @@ discard_confusing_lines (struct file_data filevec[])
> /* Set up equiv_count[F][I] as the number of lines in file F
> that fall in equivalence class I. */
>
> - p = zalloc (filevec[0].equiv_max * (2 * sizeof *p));
> + p = xcalloc (filevec[0].equiv_max, 2 * sizeof *p);
The commit message claims they are all changed to xzalloc, but this
one is changed to xcalloc. Looking further...
> @@ -78,8 +78,8 @@ discard_confusing_lines (struct file_data filevec[])
>
> /* Set up tables of which lines are going to be discarded. */
>
> - discarded[0] = zalloc (filevec[0].buffered_lines
> - + filevec[1].buffered_lines);
> + discarded[0] = xzalloc (filevec[0].buffered_lines
> + + filevec[1].buffered_lines);
This matches the commit,
> +++ b/src/io.c
> @@ -806,7 +806,7 @@ read_files (struct file_data filevec[], bool
> pretend_binary)
> nbuckets = ((size_t) 1 << i) - prime_offset[i];
> if (PTRDIFF_MAX / sizeof *buckets <= nbuckets)
> xalloc_die ();
> - buckets = zalloc ((nbuckets + 1) * sizeof *buckets);
> + buckets = xcalloc (nbuckets + 1, sizeof *buckets);
...and here's another xcalloc.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
- Re: [PATCH 04/17] maint: zalloc → xzalloc,
Eric Blake <=