diff options
author | Jim McDonough <jmcd@samba.org> | 2002-05-16 20:06:00 +0000 |
---|---|---|
committer | Jim McDonough <jmcd@samba.org> | 2002-05-16 20:06:00 +0000 |
commit | 276e1928c4557da1fd7ca8e1232a652331f3a488 (patch) | |
tree | e429cb3179a885325b3187916a9e42d0ef9ac1f3 /source3/lib | |
parent | a3c7cbfed365d77c78b4eceecefde6c3536ba85f (diff) | |
download | samba-276e1928c4557da1fd7ca8e1232a652331f3a488.tar.gz samba-276e1928c4557da1fd7ca8e1232a652331f3a488.tar.bz2 samba-276e1928c4557da1fd7ca8e1232a652331f3a488.zip |
Add __va_copy to talloc functions. talloc_asprintf was causing all kinds
of problems on Linux/390 systems...
(This used to be commit 2605e483b309e62b4c5d39a2ac6d8b2257bb5a87)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/talloc.c | 29 |
1 files 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; } |