]> git.tuebingen.mpg.de Git - paraslash.git/commit
Replace PARA_VSNPRINTF by xvasprintf().
authorAndre Noll <maan@systemlinux.org>
Fri, 6 Jan 2012 03:15:34 +0000 (04:15 +0100)
committerAndre Noll <maan@systemlinux.org>
Fri, 20 Jan 2012 21:57:07 +0000 (22:57 +0100)
commit3e6bba778c867a8977704b5c15e52fa18fb0d900
treee255b1b66bbf1dfefd51d9909f205499f80ef63d
parent69b3a249fb8f0f4a01e26f7a414dbe79f480a78c
Replace PARA_VSNPRINTF by xvasprintf().

The PARA_VSNPRINTF macro is rather clumsy, and too large to be inlined.
Moreover, it does not return the length of the formated string, so
users have to call strlen() after the call to PARA_VSNPRINTF(). This
is extra work which can easily be avoided since the number of bytes
written is returned by the underlying call to vsnprintf().

This patch replaces the macro by the public function xvasprintf(),
which is similar to the non-standard vasprintf() on GNU systems. It
also adds xasprintf(), a similar variant which takes a variable number
of arguments.

Unlike PARA_VSNPRINTF, xasprintf() and xvasprintf() return the number
of bytes written. This relies on vsnprintf() conforming to the C99
standard and breaks in particular on glibc 2.0 systems. Since glibc
2.0 is about 15 years old, this is unlikely to cause problems on
real systems.

All users which called strlen() right after xvasprintf() are changed
to use the return value of xvasprintf() instead.
crypt_common.c
fd.c
gcc-compat.h
gui.c
para.h
string.c
string.h