summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2001-10-13 12:47:59 +0000
committerSimo Sorce <idra@samba.org>2001-10-13 12:47:59 +0000
commitb7bd7ea153bfd692a54e4eb7135c3ca33292f636 (patch)
treea9e550db2ce91f2ba33ea2b1dad6a3f2e8449866 /source3/lib
parent812dcab195504301faea7443f1cb900dea57a823 (diff)
downloadsamba-b7bd7ea153bfd692a54e4eb7135c3ca33292f636.tar.gz
samba-b7bd7ea153bfd692a54e4eb7135c3ca33292f636.tar.bz2
samba-b7bd7ea153bfd692a54e4eb7135c3ca33292f636.zip
introduce mangle backward compatibility functions
add talloc_asprintf() (This used to be commit 7264d611eff871f424d449e1ff1c7ec3f5fdde40)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/talloc.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/source3/lib/talloc.c b/source3/lib/talloc.c
index 97ba196e2a..05f4351aaf 100644
--- a/source3/lib/talloc.c
+++ b/source3/lib/talloc.c
@@ -165,3 +165,34 @@ char *talloc_strdup(TALLOC_CTX *t, char *p)
{
return talloc_memdup(t, p, strlen(p) + 1);
}
+
+/* allocate a bit of memory from the specified pool */
+char *talloc_asprintf(TALLOC_CTX *t, const char *fmt, ...)
+{
+ struct talloc_chunk *tc;
+ va_list ap;
+ char *str;
+ size_t ret;
+
+ tc = malloc(sizeof(*tc));
+ if (!tc)
+ return NULL;
+
+ va_start(ap, fmt);
+ ret = vasprintf(&str, fmt, ap);
+ va_end(ap);
+ if (ret <= 0)
+ {
+ SAFE_FREE(tc);
+ return NULL;
+ }
+
+ tc->ptr = str;
+ tc->size = ret + 1;
+ tc->next = t->list;
+ t->list = tc;
+ t->total_alloc_size += tc->size;
+
+ return str;
+}
+