snprintf and malloc

Freddie Chopin freddie_chopin@op.pl
Wed Dec 6 11:24:00 GMT 2017


On Tue, 2017-12-05 at 15:47 -0500, Trampas Stern wrote:
> It looks like the best option is to implement my own snprintf() and
> avoid
> using newlib's.

Not the best approach in my opinion.

You may always use sniprintf(), which does _NOT_ support any floating
point formats, but it also does _NOT_ use malloc(). Generally in newlib
there are non-floating-point variants of all printf- and scanf-like
functions - just add the "i" right before printf/scanf and you are
done. For example there is iprintf, siprintf, sniprintf, viprintf and
so on.

Regards,
FCh



More information about the Newlib mailing list