summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/include/talloc.h3
-rw-r--r--source4/lib/data_blob.c3
-rw-r--r--source4/lib/talloc.c25
3 files changed, 20 insertions, 11 deletions
diff --git a/source4/include/talloc.h b/source4/include/talloc.h
index 9f7281f427..e329bdb308 100644
--- a/source4/include/talloc.h
+++ b/source4/include/talloc.h
@@ -38,6 +38,7 @@ typedef void TALLOC_CTX;
#define talloc_p(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type)
#define talloc_array_p(ctx, type, count) (type *)talloc_array(ctx, sizeof(type), count, __location__)
#define talloc_realloc_p(p, type, count) (type *)talloc_realloc_array(p, sizeof(type), count, __location__)
+#define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__)
#define talloc_destroy(ctx) talloc_free(ctx)
@@ -45,5 +46,7 @@ typedef void TALLOC_CTX;
#define malloc_array_p(type, count) (type *)realloc_array(NULL, sizeof(type), count)
#define realloc_p(p, type, count) (type *)realloc_array(p, sizeof(type), count)
+#define data_blob(ptr, size) data_blob_named(ptr, size, __location__)
+
#endif
diff --git a/source4/lib/data_blob.c b/source4/lib/data_blob.c
index c8c57849d2..b09148b63e 100644
--- a/source4/lib/data_blob.c
+++ b/source4/lib/data_blob.c
@@ -25,7 +25,7 @@
construct a data blob, must be freed with data_blob_free()
you can pass NULL for p and get a blank data blob
*******************************************************************/
-DATA_BLOB data_blob(const void *p, size_t length)
+DATA_BLOB data_blob_named(const void *p, size_t length, const char *name)
{
DATA_BLOB ret;
@@ -43,6 +43,7 @@ DATA_BLOB data_blob(const void *p, size_t length)
ret.length = 0;
return ret;
}
+ talloc_set_name_const(ret.data, name);
ret.length = length;
return ret;
}
diff --git a/source4/lib/talloc.c b/source4/lib/talloc.c
index c08495aae4..1d781e4101 100644
--- a/source4/lib/talloc.c
+++ b/source4/lib/talloc.c
@@ -26,9 +26,6 @@
#include "includes.h"
-#undef talloc
-#define talloc(ctx, size) _talloc(ctx, size)
-
#define MAX_TALLOC_SIZE 0x10000000
#define TALLOC_MAGIC 0xe814ec4f
#define TALLOC_MAGIC_FREE 0x7faebef3
@@ -171,7 +168,7 @@ void *talloc_named(void *context, size_t size,
va_list ap;
void *ptr;
- ptr = talloc(context, size);
+ ptr = _talloc(context, size);
if (ptr == NULL) {
return NULL;
}
@@ -192,7 +189,7 @@ void *talloc_named_const(void *context, size_t size, const char *name)
{
void *ptr;
- ptr = talloc(context, size);
+ ptr = _talloc(context, size);
if (ptr == NULL) {
return NULL;
}
@@ -222,7 +219,7 @@ void *talloc_init(const char *fmt, ...) _PRINTF_ATTRIBUTE(1,2)
va_list ap;
void *ptr;
- ptr = talloc(NULL, 0);
+ ptr = _talloc(NULL, 0);
if (ptr == NULL) {
return NULL;
}
@@ -438,7 +435,7 @@ static void talloc_report_all(void)
*/
void talloc_enable_leak_check(void)
{
- null_context = talloc_named(NULL, 0, "null_context");
+ null_context = talloc_named_const(NULL, 0, "null_context");
atexit(talloc_report_all);
}
@@ -460,12 +457,13 @@ void *talloc_zero(void *t, size_t size)
/*
memdup with a talloc.
*/
-void *talloc_memdup(void *t, const void *p, size_t size)
+void *_talloc_memdup(void *t, const void *p, size_t size, const char *name)
{
- void *newp = talloc(t,size);
+ void *newp = _talloc(t,size);
if (newp) {
memcpy(newp, p, size);
+ talloc_set_name_const(newp, name);
}
return newp;
@@ -476,10 +474,15 @@ void *talloc_memdup(void *t, const void *p, size_t size)
*/
char *talloc_strdup(void *t, const char *p)
{
+ char *ret;
if (!p) {
return NULL;
}
- return talloc_memdup(t, p, strlen(p) + 1);
+ ret = talloc_memdup(t, p, strlen(p) + 1);
+ if (ret) {
+ talloc_set_name_const(ret, ret);
+ }
+ return ret;
}
/*
@@ -511,6 +514,7 @@ char *talloc_vasprintf(void *t, const char *fmt, va_list ap) _PRINTF_ATTRIBUTE(2
if (ret) {
VA_COPY(ap2, ap);
vsnprintf(ret, len+1, fmt, ap2);
+ talloc_set_name_const(ret, ret);
}
return ret;
@@ -563,6 +567,7 @@ static char *talloc_vasprintf_append(char *s,
VA_COPY(ap2, ap);
vsnprintf(s+s_len, len+1, fmt, ap2);
+ talloc_set_name_const(s, s);
return s;
}