summaryrefslogtreecommitdiff
path: root/source3/lib/talloc.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2002-07-15 10:35:28 +0000
committerAndrew Tridgell <tridge@samba.org>2002-07-15 10:35:28 +0000
commite90b65284812aaa5ff9e9935ce9bbad7791cbbcd (patch)
tree9e744d1dc2f93934a4b49166a37383d3cb2b2139 /source3/lib/talloc.c
parentec167dc9cc0ec2ee461837c25a371d2981744208 (diff)
downloadsamba-e90b65284812aaa5ff9e9935ce9bbad7791cbbcd.tar.gz
samba-e90b65284812aaa5ff9e9935ce9bbad7791cbbcd.tar.bz2
samba-e90b65284812aaa5ff9e9935ce9bbad7791cbbcd.zip
updated the 3.0 branch from the head branch - ready for alpha18
(This used to be commit 03ac082dcb375b6f3ca3d810a6a6367542bc23ce)
Diffstat (limited to 'source3/lib/talloc.c')
-rw-r--r--source3/lib/talloc.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/source3/lib/talloc.c b/source3/lib/talloc.c
index 6ac784a929..0f293e1725 100644
--- a/source3/lib/talloc.c
+++ b/source3/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;
}