diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-09-26 06:41:59 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:59:17 -0500 |
commit | dbc2346de8b2f213d8bb7e647c4f187c6103e474 (patch) | |
tree | 10b975ec014419124eee3bff6ee23f857acb7a0f /source4/lib | |
parent | df6dce1065d4323ebf8ca97b69f0a44804f19e11 (diff) | |
download | samba-dbc2346de8b2f213d8bb7e647c4f187c6103e474.tar.gz samba-dbc2346de8b2f213d8bb7e647c4f187c6103e474.tar.bz2 samba-dbc2346de8b2f213d8bb7e647c4f187c6103e474.zip |
r2653: - data_blob() and data_blob_talloc() now get automatic names
- talloc_strdup() and related functions get automatic names
(This used to be commit 0cf427d14fe0a19cb3e85b6191be220f3d81080a)
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/data_blob.c | 3 | ||||
-rw-r--r-- | source4/lib/talloc.c | 25 |
2 files changed, 17 insertions, 11 deletions
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; } |