public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: NIIBE Yutaka <gniibe@m17n.org>
To: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: snprintf documentation fix
Date: Wed, 25 Jan 2006 05:49:00 -0000	[thread overview]
Message-ID: <43D71150.7080002@m17n.org> (raw)

Hi there,

I found a bug in the example code of snprintf in the documentation.
It explains as follows:

    Function snprintf returns number of characters needed to output.
    Using that value, it reallocates buffer and calls snprintf again.

However, second call of snprintf has same argument for SIZE even
though the buffer has bigger size.

How about following change?

Index: manual/stdio.texi
===================================================================
RCS file: /cvs/glibc/libc/manual/stdio.texi,v
retrieving revision 1.135
diff -u -3 -p -r1.135 stdio.texi
--- manual/stdio.texi	15 Dec 2005 22:30:34 -0000	1.135
+++ manual/stdio.texi	25 Jan 2006 05:11:08 -0000
@@ -2357,7 +2357,8 @@ make_message (char *name, char *value)
     @{
       /* @r{Reallocate buffer now that we know
          how much space is needed.} */
-      buffer = (char *) xrealloc (buffer, nchars + 1);
+      size = nchars + 1;
+      buffer = (char *) xrealloc (buffer, size);

       if (buffer != NULL)
         /* @r{Try again.} */

             reply	other threads:[~2006-01-25  5:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-25  5:49 NIIBE Yutaka [this message]
2006-02-04  7:14 ` Ulrich Drepper

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=43D71150.7080002@m17n.org \
    --to=gniibe@m17n.org \
    --cc=libc-hacker@sources.redhat.com \
    /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).