1 /* Copyright (C) 2007, 2008 Eric Blake
2 * Permission to use, copy, modify, and distribute this software
3 * is freely granted, provided that this notice is preserved.
5 /* This code was derived from asprintf.c */
6 /* doc in viprintf.c */
17 _vasniprintf_r (struct _reent
*ptr
,
29 /* mark an existing buffer, but allow allocation of larger string */
30 f
._flags
= __SWR
| __SSTR
| __SOPT
;
34 /* mark a zero-length reallocatable buffer */
35 f
._flags
= __SWR
| __SSTR
| __SMBF
;
40 f
._bf
._base
= f
._p
= (unsigned char *) buf
;
41 /* For now, inherit the 32-bit signed limit of FILE._bf._size.
42 FIXME - it would be nice to rewrite sys/reent.h to support size_t
46 _REENT_ERRNO(ptr
) = EOVERFLOW
;
49 f
._bf
._size
= f
._w
= len
;
50 f
._file
= -1; /* No file. */
51 ret
= _svfiprintf_r (ptr
, &f
, fmt
, ap
);
56 return (char *) f
._bf
._base
;
62 vasniprintf (char *buf
,
67 return _vasniprintf_r (_REENT
, buf
, lenp
, fmt
, ap
);
70 #endif /* ! _REENT_ONLY */