From: Andreas Schwab <schwab@suse.de>
To: fweimer@redhat.com (Florian Weimer)
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH] manual: Various fixes to the mbstouwcs example
Date: Wed, 04 Apr 2018 14:19:00 -0000 [thread overview]
Message-ID: <mvm370b3vgh.fsf@suse.de> (raw)
In-Reply-To: <20180404135740.A283E406F5A23@oldenburg.str.redhat.com> (Florian Weimer's message of "Wed, 04 Apr 2018 15:57:40 +0200")
On Apr 04 2018, fweimer@redhat.com (Florian Weimer) wrote:
> diff --git a/manual/examples/mbstouwcs.c b/manual/examples/mbstouwcs.c
> index 3a8b9a65f9..4012606bf1 100644
> --- a/manual/examples/mbstouwcs.c
> +++ b/manual/examples/mbstouwcs.c
> @@ -7,8 +7,11 @@
> wchar_t *
> mbstouwcs (const char *s)
> {
> - size_t len = strlen (s);
> - wchar_t *result = malloc ((len + 1) * sizeof (wchar_t));
> + /* Include the NUL terminator in the conversion. */
> + size_t len = strlen (s) + 1;
> + wchar_t *result = reallocarray (NULL, len + 1, sizeof (wchar_t));
What is result[len] used for?
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
next prev parent reply other threads:[~2018-04-04 14:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-04 13:57 Florian Weimer
2018-04-04 14:19 ` Andreas Schwab [this message]
2018-04-05 9:56 ` Florian Weimer
2018-04-05 10:08 ` Andreas Schwab
2018-04-05 10:13 ` Florian Weimer
2018-04-05 10:49 ` Andreas Schwab
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=mvm370b3vgh.fsf@suse.de \
--to=schwab@suse.de \
--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).