mailing list of musl libc
 help / color / mirror / code / Atom feed
* looking at fmtmsg-is dprintf oom-safe?
@ 2014-04-24 16:57 Isaac Dunham
  2014-04-25 14:50 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Isaac Dunham @ 2014-04-24 16:57 UTC (permalink / raw)
  To: musl

Hello,
I've been poking at fmtmsg(), since if I added that and used sdbm for
dbm.h, I'd have XSI coverage.
Due to the use case for fmtmsg (reporting errors, including terminal
errors), I expect it needs to work even when malloc() fails.
My understanding is that this would exclude using fopen().

I could use several calls to write() (I currently have a preliminary
version that does this), but dprintf() would be more optimal.
As far as I can tell, dprintf() should still work when malloc() fails,
but I'd like to confirm this.

Thanks,
Isaac Dunham



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: looking at fmtmsg-is dprintf oom-safe?
  2014-04-24 16:57 looking at fmtmsg-is dprintf oom-safe? Isaac Dunham
@ 2014-04-25 14:50 ` Rich Felker
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2014-04-25 14:50 UTC (permalink / raw)
  To: musl

On Thu, Apr 24, 2014 at 09:57:44AM -0700, Isaac Dunham wrote:
> Hello,
> I've been poking at fmtmsg(), since if I added that and used sdbm for
> dbm.h, I'd have XSI coverage.
> Due to the use case for fmtmsg (reporting errors, including terminal
> errors), I expect it needs to work even when malloc() fails.
> My understanding is that this would exclude using fopen().
> 
> I could use several calls to write() (I currently have a preliminary
> version that does this), but dprintf() would be more optimal.
> As far as I can tell, dprintf() should still work when malloc() fails,
> but I'd like to confirm this.

Yes, dprintf runs in O(1) memory (stack) and is async-signal-safe. The
stack usage is tiny unless you're printing floating point, and in the
fp case, something like 512 bytes to 8k depending on arch the size of
long double.

Rich



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-04-25 14:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-24 16:57 looking at fmtmsg-is dprintf oom-safe? Isaac Dunham
2014-04-25 14:50 ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).