s3-events: Do not vasprintf() the tevent debug messages that will not be shown
authorAndrew Bartlett <abartlet@samba.org>
Thu, 9 Aug 2012 08:34:28 +0000 (18:34 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 9 Aug 2012 10:14:22 +0000 (20:14 +1000)
This malloc() and free() actually shows up quite high on a call profile of
provision of the AD DC (and this is the matching patch for source3).

Andrew Bartlett

source3/lib/events.c

index 72fd40ef598adccbf14f6896a00f9bb7e13e11c0..cafe598ca0940ce6c6089b41deb4c13fd15e41bd 100644 (file)
@@ -434,11 +434,13 @@ static void s3_event_debug(void *context, enum tevent_debug_level level,
                break;
 
        };
-       if (vasprintf(&s, fmt, ap) == -1) {
-               return;
+       if (CHECK_DEBUGLVL(samba_level)) {
+               if (vasprintf(&s, fmt, ap) == -1) {
+                       return;
+               }
+               DEBUG(samba_level, ("s3_event: %s", s));
+               free(s);
        }
-       DEBUG(samba_level, ("s3_event: %s", s));
-       free(s);
 }
 
 struct tevent_context *s3_tevent_context_init(TALLOC_CTX *mem_ctx)