~jkaivo/asprintf

a simple inline implementation of the GNU functions asprintf() and vasprintf()
1bff06e0 — Jakob Kaivo 2 years ago
adjust error check of initial call to vsnprintf() to account for the fact that we always add 1
bd10656e — Jakob Kaivo 2 years ago
Add README.md
28709230 — Jakob Kaivo 2 years ago
Add LICENSE

refs

asprintf
browse  log 

clone

read-only
https://git.sr.ht/~jkaivo/asprintf
read/write
git@git.sr.ht:~jkaivo/asprintf

You can also use your local clone with git send-email.

This is a simple inline implementation of the GNU functions asprintf() and vasprintf(). This header requires only a conforming C99 (or higher) compiler and standard library.

The usage is identical to your system's sprintf() and vsprintf(), respectively, except that the first argument is a pointer to a pointer to char, rather than a pointer directly to a char buffer. On a successful call, a new buffer large enough to hold the resulting string is allocated and assigned through the first parameter. This buffer must be passed to free() to avoid memory leaks.