diff options
Diffstat (limited to 'source4/lib')
-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: |