diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-03-26 10:47:44 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:11:17 -0500 |
commit | 0d36266cd4e0034ca5ed2755084a64db3e235ac4 (patch) | |
tree | 73d8d54a3e1d5122b48e2d015c10e9c61465dab1 /source4 | |
parent | 0c936acc47062f2c3589bd2916c10037c49e0db9 (diff) | |
download | samba-0d36266cd4e0034ca5ed2755084a64db3e235ac4.tar.gz samba-0d36266cd4e0034ca5ed2755084a64db3e235ac4.tar.bz2 samba-0d36266cd4e0034ca5ed2755084a64db3e235ac4.zip |
r6075: added talloc_enable_null_tracking() (asked for by lifeless)
(This used to be commit 40b8ee186af3e7f771c680dbbb03fdcf559bf103)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/talloc/talloc.c | 14 | ||||
-rw-r--r-- | source4/lib/talloc/talloc.h | 1 | ||||
-rw-r--r-- | source4/lib/talloc/talloc_guide.txt | 8 |
3 files changed, 21 insertions, 2 deletions
diff --git a/source4/lib/talloc/talloc.c b/source4/lib/talloc/talloc.c index 0d78dd8d24..661282a87d 100644 --- a/source4/lib/talloc/talloc.c +++ b/source4/lib/talloc/talloc.c @@ -812,11 +812,21 @@ static void talloc_report_null_full(void) } /* + enable tracking of the NULL context +*/ +void talloc_enable_null_tracking(void) +{ + if (null_context == NULL) { + null_context = talloc_named_const(NULL, 0, "null_context"); + } +} + +/* enable leak reporting on exit */ void talloc_enable_leak_report(void) { - null_context = talloc_named_const(NULL, 0, "null_context"); + talloc_enable_null_tracking(); atexit(talloc_report_null); } @@ -825,7 +835,7 @@ void talloc_enable_leak_report(void) */ void talloc_enable_leak_report_full(void) { - null_context = talloc_named_const(NULL, 0, "null_context"); + talloc_enable_null_tracking(); atexit(talloc_report_null_full); } diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index f639f3c8cf..8b448f63c5 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -110,6 +110,7 @@ off_t talloc_total_size(const void *ptr); off_t talloc_total_blocks(const void *ptr); void talloc_report_full(const void *ptr, FILE *f); void talloc_report(const void *ptr, FILE *f); +void talloc_enable_null_tracking(void); void talloc_enable_leak_report(void); void talloc_enable_leak_report_full(void); void *_talloc_zero(const void *ctx, size_t size, const char *name); diff --git a/source4/lib/talloc/talloc_guide.txt b/source4/lib/talloc/talloc_guide.txt index aca3ab4937..7d6dfa5cb2 100644 --- a/source4/lib/talloc/talloc_guide.txt +++ b/source4/lib/talloc/talloc_guide.txt @@ -409,6 +409,14 @@ full talloc report on 'root' (total 18 bytes in 8 blocks) =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +void talloc_enable_null_tracking(void); + +This enables tracking of the NULL memory context without enabling leak +reporting on exit. Useful for when you want to do your own leak +reporting call via talloc_report_null_full(); + + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- (type *)talloc_zero(const void *ctx, type); The talloc_zero() macro is equivalent to: |