From: root Date: Thu, 10 Mar 2011 01:10:40 +0000 (-0800) Subject: Disable profiling collection entirely when no data is requested X-Git-Url: https://git.vrable.net/?a=commitdiff_plain;h=04b536cbc34449b9abac023e188926bd802fef9f;p=bluesky.git Disable profiling collection entirely when no data is requested --- 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);