Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2002-07-04 22:56:17 +0400
committerJeff Johnston <jjohnstn@redhat.com>2002-07-04 22:56:17 +0400
commit7501704dc9dc7337e621db87ada8901a496766d9 (patch)
tree8b0549b249b4f5fd48d0ee389d5db48beea55491 /newlib/libc/stdio/fvwrite.c
parent5cff62d6561dc63ef30b57d7ee415e6e1acdfb70 (diff)
2002-07-04 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdio/Makefile.am: Add asprintf.c and vasprintf.c. * libc/stdio/Makefile.in: Regenerated. * libc/stdio/asprintf.c: New file. * libc/stdio/vasprintf.c: Ditto. * libc/stdio/fvwrite.c: Add code to dynamically reallocate the buffer for asprintf support. * libc/stdio/sprintf.c: Add asprintf documentation. * libc/stdio/vfprintf.c: Add vasprintf documentation. * libc/include/stdio.h: Add new prototypes.
Diffstat (limited to 'newlib/libc/stdio/fvwrite.c')
-rw-r--r--newlib/libc/stdio/fvwrite.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/newlib/libc/stdio/fvwrite.c b/newlib/libc/stdio/fvwrite.c
index 62d0ba072..fe0e80111 100644
--- a/newlib/libc/stdio/fvwrite.c
+++ b/newlib/libc/stdio/fvwrite.c
@@ -19,6 +19,7 @@
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
#include "local.h"
#include "fvwrite.h"
@@ -110,7 +111,9 @@ __sfvwrite (fp, uio)
* as fit, but pretend we wrote everything. This makes
* snprintf() return the number of bytes needed, rather
* than the number used, and avoids its write function
- * (so that the write function can be invalid).
+ * (so that the write function can be invalid). If
+ * we are dealing with the asprintf routines, we will
+ * dynamically increase the buffer size as needed.
*/
do
{
@@ -118,6 +121,19 @@ __sfvwrite (fp, uio)
w = fp->_w;
if (fp->_flags & __SSTR)
{
+ if (len > w && fp->_flags & __SMBF)
+ { /* must be asprintf family */
+ unsigned char *ptr;
+ int curpos = (fp->_p - fp->_bf._base);
+ ptr = (unsigned char *)_realloc_r (fp->_data, fp->_bf._base,
+ curpos + len);
+ if (!ptr)
+ goto err;
+ fp->_bf._base = ptr;
+ fp->_p = ptr + curpos;
+ fp->_bf._size = curpos + len;
+ w = fp->_w = len;
+ }
if (len < w)
w = len;
COPY (w); /* copy MIN(fp->_w,len), */