- default to using va_copy(), thus assuming a modern libc
#include <stdarg.h>
#include <stdint.h>
#include "talloc.h"
+/* assume a modern system */
+#define HAVE_VA_COPY
#endif
/* use this to force every realloc to change the pointer, to stress test
static char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap)
{
- struct talloc_chunk *tc = talloc_chunk_from_ptr(s);
+ struct talloc_chunk *tc;
int len, s_len;
va_list ap2;
+ if (s == NULL) {
+ return talloc_vasprintf(NULL, fmt, ap);
+ }
+
+ tc = talloc_chunk_from_ptr(s);
+
VA_COPY(ap2, ap);
s_len = tc->size - 1;