From 04b536cbc34449b9abac023e188926bd802fef9f Mon Sep 17 00:00:00 2001 From: root Date: Wed, 9 Mar 2011 17:10:40 -0800 Subject: [PATCH] Disable profiling collection entirely when no data is requested --- bluesky/util.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bluesky/util.c b/bluesky/util.c index 3898c4a..3652d1a 100644 --- a/bluesky/util.c +++ b/bluesky/util.c @@ -353,6 +353,8 @@ typedef struct { /* To catch attempts to access to invalid profile structures. */ #define PROFILE_MAGIC 0x439929d8 +static FILE *profiling_file = NULL; + BlueSkyProfile *bluesky_profile_new() { BlueSkyProfile *profile = g_new0(BlueSkyProfile, 1); @@ -381,6 +383,9 @@ void bluesky_profile_free(BlueSkyProfile *profile) void bluesky_profile_add_event(BlueSkyProfile *profile, char *message) { + if (profiling_file == NULL) + return; + g_return_if_fail(profile != NULL); if (profile->magic != PROFILE_MAGIC) { @@ -397,7 +402,6 @@ void bluesky_profile_add_event(BlueSkyProfile *profile, char *message) g_mutex_unlock(profile->lock); } -static FILE *profiling_file = NULL; static GStaticMutex profiling_print_lock = G_STATIC_MUTEX_INIT; void bluesky_profile_set_output(FILE *stream) @@ -407,9 +411,9 @@ void bluesky_profile_set_output(FILE *stream) void bluesky_profile_print(BlueSkyProfile *profile) { - if (profiling_file == NULL) - return; FILE *stream = profiling_file; + if (stream == NULL) + return; g_return_if_fail(profile != NULL); -- 2.20.1