From 276e1928c4557da1fd7ca8e1232a652331f3a488 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Thu, 16 May 2002 20:06:00 +0000 Subject: Add __va_copy to talloc functions. talloc_asprintf was causing all kinds of problems on Linux/390 systems... (This used to be commit 2605e483b309e62b4c5d39a2ac6d8b2257bb5a87) --- source3/lib/talloc.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/source3/lib/talloc.c b/source3/lib/talloc.c index b50e451b95..b66d674dd5 100644 --- a/source3/lib/talloc.c +++ b/source3/lib/talloc.c @@ -316,12 +316,22 @@ smb_ucs2_t *talloc_strdup_w(TALLOC_CTX *t, const smb_ucs2_t *p) { int len; char *ret; + va_list ap2; - len = vsnprintf(NULL, 0, fmt, ap); +#ifdef HAVE_VA_COPY + __va_copy(ap2, ap); /* for systems were va_list is a struct */ +#else + ap2 = ap; +#endif + len = vsnprintf(NULL, 0, fmt, ap2); ret = talloc(t, len+1); - if (ret) - vsnprintf(ret, len+1, fmt, ap); + if (ret) { +#ifdef HAVE_VA_COPY + __va_copy(ap2, ap); +#endif + vsnprintf(ret, len+1, fmt, ap2); + } return ret; } @@ -354,14 +364,23 @@ smb_ucs2_t *talloc_strdup_w(TALLOC_CTX *t, const smb_ucs2_t *p) const char *fmt, va_list ap) { int len, s_len; + va_list ap2; +#ifdef HAVE_VA_COPY + __va_copy(ap2, ap); +#else + ap2 = ap; +#endif s_len = strlen(s); - len = vsnprintf(NULL, 0, fmt, ap); + len = vsnprintf(NULL, 0, fmt, ap2); s = talloc_realloc(t, s, s_len + len+1); if (!s) return NULL; - vsnprintf(s+s_len, len+1, fmt, ap); +#ifdef HAVE_VA_COPY + __va_copy(ap2, ap); +#endif + vsnprintf(s+s_len, len+1, fmt, ap2); return s; } -- cgit