[MPlayer-cvslog] r33685 - trunk/mp_strings.c

reimar subversion at mplayerhq.hu
Mon Jun 20 22:10:29 CEST 2011


Author: reimar
Date: Mon Jun 20 22:10:28 2011
New Revision: 33685

Log:
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.

Modified:
   trunk/mp_strings.c

Modified: trunk/mp_strings.c
==============================================================================
--- trunk/mp_strings.c	Mon Jun 20 01:52:04 2011	(r33684)
+++ trunk/mp_strings.c	Mon Jun 20 22:10:28 2011	(r33685)
@@ -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 @@ char *mp_asprintf(const char *fmt, ...)
     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;
 }


More information about the MPlayer-cvslog mailing list