Add debug_ctx according to an idea by Tridge
authorVolker Lendecke <vl@samba.org>
Sat, 15 Dec 2007 20:05:11 +0000 (21:05 +0100)
committerVolker Lendecke <vl@samba.org>
Sat, 15 Dec 2007 21:09:35 +0000 (22:09 +0100)
Sorry, Jeremy, I think for debug messages this is just the right way to do it.
(This used to be commit 6312016e2727c2b5b1a4964a98cfb9585d77cc8c)

source3/lib/debug.c

index 185c2373f4593c382241c632fca6ac4fb7994891..87ec9ed8f577a9f948b404a296aaaea6067953a8 100644 (file)
@@ -90,6 +90,7 @@ bool    AllowDebugChange = True;
 */
 bool    override_logfile;
 
+static TALLOC_CTX *tmp_debug_ctx;
 
 /*
  * This is to allow assignment to DEBUGLEVEL before the debug
@@ -856,6 +857,8 @@ void check_log_size( void )
 
        errno = old_errno;
 
+       TALLOC_FREE(tmp_debug_ctx);
+
        return( 0 );
 }
 
@@ -1065,3 +1068,14 @@ bool dbghdr(int level, int cls, const char *file, const char *func, int line)
        SAFE_FREE(msgbuf);
        return ret;
 }
+
+/*
+ * Get us a temporary talloc context usable just for DEBUG arguments
+ */
+TALLOC_CTX *debug_ctx(void)
+{
+        if (tmp_debug_ctx == NULL) {
+                tmp_debug_ctx = talloc_named_const(NULL, 0, "debug_ctx");
+        }
+        return tmp_debug_ctx;
+}