talloc_stack: abort in developer me if no stackframe on talloc_tos()
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 18 Jul 2012 05:37:27 +0000 (15:07 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 18 Jul 2012 05:37:27 +0000 (15:07 +0930)
Don't tolerate leaks in developer mode.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
lib/util/talloc_stack.c
lib/util/talloc_stack.h

index be332af571b54c84ce3534b5c72fb0a48a4a4efd..9c72c801197b2b8f4bcd7fd7627957a4702a700d 100644 (file)
@@ -188,15 +188,19 @@ TALLOC_CTX *_talloc_stackframe_pool(const char *location, size_t poolsize)
  * Get us the current top of the talloc stack.
  */
 
-TALLOC_CTX *talloc_tos(void)
+TALLOC_CTX *_talloc_tos(const char *location)
 {
        struct talloc_stackframe *ts =
                (struct talloc_stackframe *)SMB_THREAD_GET_TLS(global_ts);
 
        if (ts == NULL || ts->talloc_stacksize == 0) {
-               talloc_stackframe();
+               _talloc_stackframe(location);
                ts = (struct talloc_stackframe *)SMB_THREAD_GET_TLS(global_ts);
-               DEBUG(0, ("no talloc stackframe around, leaking memory\n"));
+               DEBUG(0, ("no talloc stackframe at %s, leaking memory\n",
+                         location));
+#ifdef DEVELOPER
+               smb_panic("No talloc stackframe");
+#endif
        }
 
        return ts->talloc_stack[ts->talloc_stacksize-1];
index 8e1644624ba49f1003e397cb0683024bc91559a9..2f5dcab0a38c606d8d07676c0f90bb57938f509b 100644 (file)
@@ -53,7 +53,8 @@ TALLOC_CTX *_talloc_stackframe_pool(const char *location, size_t poolsize);
  * Get us the current top of the talloc stack.
  */
 
-TALLOC_CTX *talloc_tos(void);
+#define talloc_tos() _talloc_tos(__location__)
+TALLOC_CTX *_talloc_tos(const char *location);
 
 /*
  * return true if a talloc stackframe exists