This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] signal-safe fprintf?


On 6 March 2013 05:13, Paul Pluzhnikov <ppluzhnikov@google.com> wrote:
> It would be *really* convenent if snprintf could be split into the
> "regular" snprintf, and a snprintf_nomalloc(). The latter would return
> ENOMEM if malloc was actually required.

snprintf could use mmap directly, which is slow but at least does not
fail when there is memory available.  The alloca cutoff threshold is
currently 64K, so the mmap requests would be a minimum of 16 pages,
with the worst case for space wastage being about 6.25% of the request
(65537 bytes requested and given 69632).  That way there's no need for
such a special case function.

We could also have a magic environment variable that allows the code
to use malloc instead, reverting to old behaviour ;)


Siddhesh
-- 
http://siddhesh.in


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]