This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: sprintf without realloc?
On Tue, Sep 26, 2006 at 08:48:56AM +0200, Schwarz, Konrad wrote:
> > Hmm, from a quick look at the code, malloc() is really only needed
> > to support the "%S" and "%ls" formats (wide character strings).
>
> I suspect that it [malloc] is also used to allocate the buffer used in
> fully- and line-buffered mode, and, at least in some cases, to ensure
> that space is available for the FILE object.
look for calls to Balloc(), which calls _calloc_r() which is a macro
that expands to calloc() which usually puts you in malloc().
I run into it when formatting floating point data %f, even when called
from snprintf.
I, too would actually love to have this be static memory, or at least
pre-allocated, since libc has an apparent leak in _reclaim_reent in
1.12.0. (I don't know if it has since been fixed.)
--
Aaron J. Grier | Frye Electronics, Tigard, OR | aaron@frye.com