]> git.ozlabs.org Git - petitboot/blobdiff - lib/talloc/talloc.c
lib/talloc: Add missing va_end() calls
[petitboot] / lib / talloc / talloc.c
index c660870543a83ff4d6dcee74ac516f599bd0709b..fa34323104a23a6e252d4d5c1ab9c7965d9c4ad0 100644 (file)
   inspired by http://swapped.cc/halloc/
 */
 
-
+#if defined(HAVE_CONFIG_H)
 #include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
+#else
 /* nfsim additions */
 #define HAVE_SYS_TYPES_H
 #define HAVE_UNISTD_H
 #define HAVE_STDARG_H
 #define HAVE_STDINT_H
 #define HAVE_VA_COPY
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if !defined(NDEBUG)
+#include <assert.h>
+#define TALLOC_ABORT(reason) do{ \
+       fprintf(stderr, "%s: name: %s\n", __func__, tc->name); \
+       assert(0 && reason);} while (0)
+#endif
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -976,6 +984,7 @@ char *talloc_vasprintf(const void *t, const char *fmt, va_list ap)
                talloc_set_name_const(ret, ret);
        }
 
+       va_end(ap2);
        return ret;
 }
 
@@ -1030,6 +1039,7 @@ static char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap)
        vsnprintf(s+s_len, len+1, fmt, ap2);
        talloc_set_name_const(s, s);
 
+       va_end(ap2);
        return s;
 }