Mercurial > mplayer.hg
changeset 33597:2ef9298a81e7
Avoid va_copy, it is not generally available
(sometimes it is still called __va_copy), it was
missing a matching va_end and this approach is the
one given as example in the vsnprintf man page.
author | reimar |
---|---|
date | Mon, 20 Jun 2011 20:10:28 +0000 |
parents | cb7c33804101 |
children | 2b750a2ce45f |
files | mp_strings.c |
diffstat | 1 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mp_strings.c Sun Jun 19 23:52:04 2011 +0000 +++ b/mp_strings.c Mon Jun 20 20:10:28 2011 +0000 @@ -27,13 +27,12 @@ char *mp_asprintf(const char *fmt, ...) { char *p = NULL; - va_list va, va_bak; + va_list va; int len; va_start(va, fmt); - va_copy(va_bak, va); - len = vsnprintf(NULL, 0, fmt, va); + va_end(va); if (len < 0) goto end; @@ -41,11 +40,12 @@ if (!p) goto end; - len = vsnprintf(p, len + 1, fmt, va_bak); + va_start(va, fmt); + len = vsnprintf(p, len + 1, fmt, va); + va_end(va); if (len < 0) free(p), p = NULL; end: - va_end(va); return p; }