public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
	Florian Weimer <fweimer@redhat.com>
Cc: libc-alpha@sourceware.org, "Andreas K . Huettel" <dilfridge@gentoo.org>
Subject: Re: [PATCH v6 2/3] support: Add xreallocarray
Date: Fri, 10 Mar 2023 13:21:56 -0800	[thread overview]
Message-ID: <ad370f42-03a8-9a64-735b-69c011b64a1f@cs.ucla.edu> (raw)
In-Reply-To: <f83a9bdd-55d6-f4b8-2427-53a5f77251be@linaro.org>

On 2023-03-10 10:44, Adhemerval Zanella Netto wrote:
> 
> 
> On 10/03/23 13:49, Florian Weimer wrote:
>> * Adhemerval Zanella:
>>
>>> +void *
>>> +xreallocarray (void *p, size_t n, size_t s)
>>> +{
>>> +  void *r = reallocarray (p, n, s);
>>> +  if (r == NULL)
>>> +    oom_error ("reallocarray", n);
>>> +  return r;
>>> +}
>>
>> Isn't the failure condition more complicated?  See xrealloc.
> 
> Indeed, I will update the patch.

You can steal the source code from Gnulib, which already has 
xreallocarray in lib/xmalloc.c.

(Gnulib also has an xireallocarray which is better if you're worried 
about integer overflow, but one step at a time.)

  reply	other threads:[~2023-03-10 21:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-02 14:57 [PATCH v6 0/3] Fix opendir regression on some FS Adhemerval Zanella
2023-03-02 14:57 ` [PATCH v6 1/3] linux: Use getdents64 on non-LFS readdir Adhemerval Zanella
2023-03-02 14:57 ` [PATCH v6 2/3] support: Add xreallocarray Adhemerval Zanella
2023-03-10 16:49   ` Florian Weimer
2023-03-10 18:44     ` Adhemerval Zanella Netto
2023-03-10 21:21       ` Paul Eggert [this message]
2023-03-02 14:57 ` [PATCH v6 3/3] linux: Set internal DIR filepos as off64_t (BZ #23960, BZ #24050) Adhemerval Zanella
2023-03-10 21:41   ` Paul Eggert
2023-03-13 12:40     ` Adhemerval Zanella Netto
2023-03-13 12:45       ` Adhemerval Zanella Netto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ad370f42-03a8-9a64-735b-69c011b64a1f@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=adhemerval.zanella@linaro.org \
    --cc=dilfridge@gentoo.org \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).