1 /* Copyright (C) 2007 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 vfprintf.c */
17 _vasnprintf_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
= _svfprintf_r (ptr
, &f
, fmt
, ap
);
56 return (char *) f
._bf
._base
;
59 #ifdef _NANO_FORMATTED_IO
61 _vasniprintf_r (struct _reent
*, char *, size_t *,
62 const char *, __VALIST
)
63 _ATTRIBUTE ((__alias__("_vasnprintf_r")));
69 vasnprintf (char *buf
,
74 return _vasnprintf_r (_REENT
, buf
, lenp
, fmt
, ap
);
77 #ifdef _NANO_FORMATTED_IO
79 vasniprintf (char *, size_t *, const char *, __VALIST
)
80 _ATTRIBUTE ((__alias__("vasnprintf")));
82 #endif /* ! _REENT_ONLY */