From 0bb6053946a1572a3496958e543d5c9ddf74120b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 3 Jun 2002 03:07:24 +0000 Subject: put the ifdef for HAVE_VA_COPY in one place rather than in lots of functions (This used to be commit 1cf3228fdc20f0314d1f8e71ad710a5e548b3f72) --- source3/lib/dprintf.c | 7 ++----- source3/lib/snprintf.c | 18 +++++------------- source3/lib/talloc.c | 23 +++++++---------------- source3/lib/util.c | 8 +++----- source3/lib/xfile.c | 8 +++----- 5 files changed, 20 insertions(+), 44 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/dprintf.c b/source3/lib/dprintf.c index e3aa2c7669..f0f09e199d 100644 --- a/source3/lib/dprintf.c +++ b/source3/lib/dprintf.c @@ -42,11 +42,8 @@ int d_vfprintf(FILE *f, const char *format, va_list ap) msgstr = lang_msg(format); if (!msgstr) return -1; -#if defined(HAVE_VA_COPY) - __va_copy(ap2, ap); -#else - ap2 = ap; -#endif + VA_COPY(ap2, ap); + ret = vasprintf(&p, msgstr, ap2); lang_msg_free(msgstr); diff --git a/source3/lib/snprintf.c b/source3/lib/snprintf.c index 561e775c8f..aaad55f22a 100644 --- a/source3/lib/snprintf.c +++ b/source3/lib/snprintf.c @@ -163,11 +163,7 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args size_t currlen; va_list args; -#if defined(HAVE_VA_COPY) - __va_copy(args, args_in); -#else - args = args_in; -#endif + VA_COPY(args, args_in); state = DP_S_DEFAULT; currlen = flags = cflags = min = 0; @@ -802,20 +798,16 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) int ret; va_list ap2; -#if defined(HAVE_VA_COPY) - __va_copy(ap2, ap); -#else - ap2 = ap; -#endif + VA_COPY(ap2, ap); ret = vsnprintf(NULL, 0, format, ap2); if (ret <= 0) return ret; (*ptr) = (char *)malloc(ret+1); if (!*ptr) return -1; -#if defined(HAVE_VA_COPY) - __va_copy(ap2, ap); -#endif + + VA_COPY(ap2, ap); + ret = vsnprintf(*ptr, ret+1, format, ap2); return ret; diff --git a/source3/lib/talloc.c b/source3/lib/talloc.c index b66d674dd5..d81528588c 100644 --- a/source3/lib/talloc.c +++ b/source3/lib/talloc.c @@ -318,18 +318,13 @@ smb_ucs2_t *talloc_strdup_w(TALLOC_CTX *t, const smb_ucs2_t *p) char *ret; va_list ap2; -#ifdef HAVE_VA_COPY - __va_copy(ap2, ap); /* for systems were va_list is a struct */ -#else - ap2 = ap; -#endif + VA_COPY(ap2, ap); + len = vsnprintf(NULL, 0, fmt, ap2); ret = talloc(t, len+1); if (ret) { -#ifdef HAVE_VA_COPY - __va_copy(ap2, ap); -#endif + VA_COPY(ap2, ap); vsnprintf(ret, len+1, fmt, ap2); } @@ -366,20 +361,16 @@ smb_ucs2_t *talloc_strdup_w(TALLOC_CTX *t, const smb_ucs2_t *p) int len, s_len; va_list ap2; -#ifdef HAVE_VA_COPY - __va_copy(ap2, ap); -#else - ap2 = ap; -#endif + VA_COPY(ap2, ap); + s_len = strlen(s); len = vsnprintf(NULL, 0, fmt, ap2); s = talloc_realloc(t, s, s_len + len+1); if (!s) return NULL; -#ifdef HAVE_VA_COPY - __va_copy(ap2, ap); -#endif + VA_COPY(ap2, ap); + vsnprintf(s+s_len, len+1, fmt, ap2); return s; diff --git a/source3/lib/util.c b/source3/lib/util.c index 2fe9ec331b..fe1011668d 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1820,11 +1820,9 @@ int smb_xvasprintf(char **ptr, const char *format, va_list ap) { int n; va_list ap2; -#if defined(HAVE_VA_COPY) - __va_copy(ap2, ap); -#else - ap2 = ap; -#endif + + VA_COPY(ap2, ap); + n = vasprintf(ptr, format, ap2); if (n == -1 || ! *ptr) { smb_panic("smb_xvasprintf: out of memory"); diff --git a/source3/lib/xfile.c b/source3/lib/xfile.c index 7b97d329ae..59f9fd48ad 100644 --- a/source3/lib/xfile.c +++ b/source3/lib/xfile.c @@ -188,11 +188,9 @@ int x_vfprintf(XFILE *f, const char *format, va_list ap) char *p; int len, ret; va_list ap2; -#if defined(HAVE_VA_COPY) - __va_copy(ap2, ap); -#else - ap2 = ap; -#endif + + VA_COPY(ap2, ap); + len = vasprintf(&p, format, ap2); if (len <= 0) return len; ret = x_fwrite(p, 1, len, f); -- cgit