From b07e4933b7ed4b2452cfdd9d223eecb8c0b74fec Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 17 Jun 2011 14:22:28 +1000 Subject: talloc: added talloc_stackframe_exists() This can be used to tell if a talloc stackframe is currently available. Callers can use this to decide if they will use talloc_tos() or instead use an alternative strategy. This gives us a way to safely have calls to talloc_tos() in common code that may end up in external libraries, as long as all talloc_tos() calls in these pieces of common code check first that a stackframe is available. --- lib/util/talloc_stack.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/util/talloc_stack.h') diff --git a/lib/util/talloc_stack.h b/lib/util/talloc_stack.h index 0e8fab37598..ec0c1c6f37e 100644 --- a/lib/util/talloc_stack.h +++ b/lib/util/talloc_stack.h @@ -53,4 +53,12 @@ TALLOC_CTX *talloc_stackframe_pool(size_t poolsize); TALLOC_CTX *talloc_tos(void); +/* + * return true if a talloc stackframe exists + * this can be used to prevent memory leaks for code that can + * optionally use a talloc stackframe (eg. nt_errstr()) + */ + +bool talloc_stackframe_exists(void); + #endif -- cgit