]> git.meshlink.io Git - catta/blobdiff - avahi-common/malloc.c
* Don't attempt to treat Known Answer records as potentially
[catta] / avahi-common / malloc.c
index 9b0e22e12b70ae7aa88065a75c2a2ef59232efae..51b8ff6aecf93e7015b08ed2c13cf9d653d91122 100644 (file)
 
 #include "malloc.h"
 
+#ifndef va_copy
+#ifdef __va_copy
+#define va_copy(DEST,SRC) __va_copy((DEST),(SRC))
+#else
+#define va_copy(DEST,SRC) memcpy(&(DEST), &(SRC), sizeof(va_list))
+#endif
+#endif
+
 static const AvahiAllocator *allocator = NULL;
 
 static void oom(void) AVAHI_GCC_NORETURN;
@@ -192,7 +200,7 @@ void avahi_set_allocator(const AvahiAllocator *a) {
 }
 
 char *avahi_strdup_vprintf(const char *fmt, va_list ap) {
-    size_t len = 100;
+    size_t len = 80;
     char *buf;
     
     assert(fmt);
@@ -203,8 +211,11 @@ char *avahi_strdup_vprintf(const char *fmt, va_list ap) {
     for (;;) {
         int n;
         char *nbuf;
-        
-        n = vsnprintf(buf, len, fmt, ap);
+        va_list ap2;
+
+        va_copy (ap2, ap);
+        n = vsnprintf(buf, len, fmt, ap2);
+        va_end (ap2);
 
         if (n >= 0 && n < (int) len)
             return buf;