diff options
author | Rob Landley <rob@landley.net> | 2007-06-15 15:16:46 -0400 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2007-06-15 15:16:46 -0400 |
commit | 0d8dfb2b905c374a65c2ca245bf588444aec5fff (patch) | |
tree | 3c87805af52fbf2056d59b2055c6d303b741743b | |
parent | 4307a7b07cec4ad8cbab47a29ba941f8cb041812 (diff) | |
download | toybox-0d8dfb2b905c374a65c2ca245bf588444aec5fff.tar.gz |
Vladimir Oleynik pointed out that va_start() twice in the same function
isn't portable (with ppc 4xx as an example of a platform it doesn't work
on). This is why va_copy exists.
-rw-r--r-- | lib/lib.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -126,22 +126,22 @@ void *xstrdup(char *s) // Die unless we can allocate enough space to sprintf() into. char *xmsprintf(char *format, ...) { - va_list va; + va_list va, va2; int len; char *ret; - // How long is it? - va_start(va, format); + va_copy(va2, va); + + // How long is it? len = vsnprintf(0, 0, format, va); len++; va_end(va); // Allocate and do the sprintf() ret = xmalloc(len); - va_start(va, format); - vsnprintf(ret, len, format, va); - va_end(va); + vsnprintf(ret, len, format, va2); + va_end(va2); return ret; } |