* snprintf documentation fix
@ 2006-01-25 5:49 NIIBE Yutaka
2006-02-04 7:14 ` Ulrich Drepper
0 siblings, 1 reply; 2+ messages in thread
From: NIIBE Yutaka @ 2006-01-25 5:49 UTC (permalink / raw)
To: Glibc hackers
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.} */
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: snprintf documentation fix
2006-01-25 5:49 snprintf documentation fix NIIBE Yutaka
@ 2006-02-04 7:14 ` Ulrich Drepper
0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Drepper @ 2006-02-04 7:14 UTC (permalink / raw)
To: NIIBE Yutaka; +Cc: Glibc hackers
[-- Attachment #1: Type: text/plain, Size: 201 bytes --]
NIIBE Yutaka wrote:
> I found a bug in the example code of snprintf in the documentation.
Patch applied.
--
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 251 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-02-04 7:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-25 5:49 snprintf documentation fix NIIBE Yutaka
2006-02-04 7:14 ` Ulrich Drepper
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).