diff options
author | Eion Robb <eion@robbmob.com> | 2008-03-04 01:01:01 +0300 |
---|---|---|
committer | Eion Robb <eion@robbmob.com> | 2008-03-04 01:01:01 +0300 |
commit | fbd94db554b00afd42fea51538cdf936fa21a8fa (patch) | |
tree | ee1282b8e5ddcbd865312ae90f281d4106d413a7 /debug.c | |
parent | 03ecb455cdda5f9656a67f773e1396193cd5e171 (diff) |
Fixed memleaks and Adium startup issues
Diffstat (limited to 'debug.c')
-rw-r--r-- | debug.c | 178 |
1 files changed, 94 insertions, 84 deletions
@@ -1,84 +1,94 @@ -#include <glib.h>
-#include <debug.h>
-
-typedef struct
-{
- PurpleDebugLevel level;
- char *category;
- char *message;
-} SkypeDebugWrapper;
-
-void
-skype_debug_vargs(PurpleDebugLevel level, const char *category,
- const char *format, va_list args);
-void skype_debug(PurpleDebugLevel level, const gchar *category,
- const gchar *format, ...);
-
-void skype_debug_info(const gchar *category, const gchar *format, ...);
-void skype_debug_warning(const gchar *category, const gchar *format, ...);
-void skype_debug_error(const gchar *category, const gchar *format, ...);
-
-gboolean skype_debug_cb(SkypeDebugWrapper *wrapper);
-
-void
-skype_debug_info(const gchar *category, const gchar *format, ...)
-{
- va_list args;
-
- va_start(args, format);
- skype_debug_vargs(PURPLE_DEBUG_INFO, category, format, args);
- va_end(args);
-}
-
-void
-skype_debug_warning(const gchar *category, const gchar *format, ...)
-{
- va_list args;
-
- va_start(args, format);
- skype_debug_vargs(PURPLE_DEBUG_WARNING, category, format, args);
- va_end(args);
-}
-
-void
-skype_debug_error(const gchar *category, const gchar *format, ...)
-{
- va_list args;
-
- va_start(args, format);
- skype_debug_vargs(PURPLE_DEBUG_ERROR, category, format, args);
- va_end(args);
-}
-
-void
-skype_debug(PurpleDebugLevel level, const char *category,
- const char *format, ...)
-{
- va_list args;
-
- va_start(args, format);
- skype_debug_vargs(level, category, format, args);
- va_end(args);
-}
-
-void
-skype_debug_vargs(PurpleDebugLevel level, const char *category,
- const char *format, va_list args)
-{
- SkypeDebugWrapper *wrapper;
-
- wrapper = g_new(SkypeDebugWrapper, 1);
- wrapper->level = level;
- wrapper->category = g_strdup(category);
- wrapper->message = g_strdup_vprintf(format, args);
-
- purple_timeout_add(1, (GSourceFunc) skype_debug_cb, (gpointer)wrapper);
-}
-
-gboolean
-skype_debug_cb(SkypeDebugWrapper *wrapper)
-{
- if (wrapper != NULL)
- purple_debug(wrapper->level, wrapper->category, wrapper->message);
- return FALSE;
-}
+#include <glib.h> +#include <debug.h> + +typedef struct +{ + PurpleDebugLevel level; + char *category; + char *message; +} SkypeDebugWrapper; + +void +skype_debug_vargs(PurpleDebugLevel level, const char *category, + const char *format, va_list args); +void skype_debug(PurpleDebugLevel level, const gchar *category, + const gchar *format, ...); + +void skype_debug_info(const gchar *category, const gchar *format, ...); +void skype_debug_warning(const gchar *category, const gchar *format, ...); +void skype_debug_error(const gchar *category, const gchar *format, ...); + +static gboolean skype_debug_cb(SkypeDebugWrapper *wrapper); + +void +skype_debug_info(const gchar *category, const gchar *format, ...) +{ + va_list args; + + va_start(args, format); + vprintf(format, args); + skype_debug_vargs(PURPLE_DEBUG_INFO, category, format, args); + va_end(args); + +} + +void +skype_debug_warning(const gchar *category, const gchar *format, ...) +{ + va_list args; + + va_start(args, format); + skype_debug_vargs(PURPLE_DEBUG_WARNING, category, format, args); + va_end(args); +} + +void +skype_debug_error(const gchar *category, const gchar *format, ...) +{ + va_list args; + + va_start(args, format); + skype_debug_vargs(PURPLE_DEBUG_ERROR, category, format, args); + va_end(args); +} + +void +skype_debug(PurpleDebugLevel level, const char *category, + const char *format, ...) +{ + va_list args; + + va_start(args, format); + skype_debug_vargs(level, category, format, args); + va_end(args); +} + +void +skype_debug_vargs(PurpleDebugLevel level, const char *category, + const char *format, va_list args) +{ + SkypeDebugWrapper *wrapper; + + if (purple_eventloop_get_ui_ops() == NULL) + { + return; + } + + wrapper = g_new(SkypeDebugWrapper, 1); + wrapper->level = level; + wrapper->category = g_strdup(category); + wrapper->message = g_strdup_vprintf(format, args); + + purple_timeout_add(1, (GSourceFunc) skype_debug_cb, (gpointer)wrapper); +} + +static gboolean +skype_debug_cb(SkypeDebugWrapper *wrapper) +{ + if (wrapper != NULL) + { + purple_debug(wrapper->level, wrapper->category, wrapper->message); + g_free(wrapper); + } + return FALSE; +} |