diff options
author | Andrew Tridgell <tridge@samba.org> | 2002-07-15 10:35:28 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2002-07-15 10:35:28 +0000 |
commit | 03ac082dcb375b6f3ca3d810a6a6367542bc23ce (patch) | |
tree | f13f085fad5de50ebe4b066eb7e2629d55032a2d /source/lib/talloc.c | |
parent | b8d39651fb90ef170055735412417239a63afc5d (diff) | |
download | samba-03ac082dcb375b6f3ca3d810a6a6367542bc23ce.tar.gz samba-03ac082dcb375b6f3ca3d810a6a6367542bc23ce.tar.xz samba-03ac082dcb375b6f3ca3d810a6a6367542bc23ce.zip |
updated the 3.0 branch from the head branch - ready for alpha18
Diffstat (limited to 'source/lib/talloc.c')
-rw-r--r-- | source/lib/talloc.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/source/lib/talloc.c b/source/lib/talloc.c index 6ac784a9297..0f293e17259 100644 --- a/source/lib/talloc.c +++ b/source/lib/talloc.c @@ -82,7 +82,7 @@ struct talloc_ctx { * @todo We should turn the global list off when using Insure++, * otherwise all the memory will be seen as still reachable. **/ -TALLOC_CTX *list_head = NULL; +static TALLOC_CTX *list_head = NULL; /** @@ -287,6 +287,15 @@ char *talloc_strdup(TALLOC_CTX *t, const char *p) return NULL; } +/** strdup_w with a talloc */ +smb_ucs2_t *talloc_strdup_w(TALLOC_CTX *t, const smb_ucs2_t *p) +{ + if (p) + return talloc_memdup(t, p, (strlen_w(p) + 1) * sizeof(smb_ucs2_t)); + else + return NULL; +} + /** * Perform string formatting, and return a pointer to newly allocated * memory holding the result, inside a memory pool. @@ -307,12 +316,17 @@ char *talloc_strdup(TALLOC_CTX *t, const char *p) { int len; char *ret; + va_list ap2; - len = vsnprintf(NULL, 0, fmt, ap); + VA_COPY(ap2, ap); + + len = vsnprintf(NULL, 0, fmt, ap2); ret = talloc(t, len+1); - if (ret) - vsnprintf(ret, len+1, fmt, ap); + if (ret) { + VA_COPY(ap2, ap); + vsnprintf(ret, len+1, fmt, ap2); + } return ret; } @@ -345,14 +359,19 @@ char *talloc_strdup(TALLOC_CTX *t, const char *p) const char *fmt, va_list ap) { int len, s_len; + va_list ap2; + + VA_COPY(ap2, ap); 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); + VA_COPY(ap2, ap); + + vsnprintf(s+s_len, len+1, fmt, ap2); return s; } |