aboutsummaryrefslogtreecommitdiff
path: root/weechat/debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'weechat/debug.c')
-rw-r--r--weechat/debug.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/weechat/debug.c b/weechat/debug.c
index c0353da..dbd1d91 100644
--- a/weechat/debug.c
+++ b/weechat/debug.c
@@ -5,7 +5,7 @@
#include "debug.h"
-static FILE *g_dfile;
+static FILE *tomsg_dfile;
void debug_init(void) {
const char *home = getenv("HOME");
@@ -17,28 +17,30 @@ void debug_init(void) {
if (!fname) return; // okay, fine, no debug file
sprintf(fname, "%s%s", home, suffix);
- g_dfile = fopen(fname, "a");
- if (!g_dfile) {
- g_dfile = NULL;
+ tomsg_dfile = fopen(fname, "a");
+ if (!tomsg_dfile) {
+ tomsg_dfile = NULL;
return; // fine!
}
+ free(fname);
+
// Disable buffering
- setvbuf(g_dfile, NULL, _IONBF, 0);
+ setvbuf(tomsg_dfile, NULL, _IONBF, 0);
- fprintf(g_dfile, "--------\n");
+ fprintf(tomsg_dfile, "--------\n");
}
void debug_deinit(void) {
- if (g_dfile) fclose(g_dfile);
+ if (tomsg_dfile) fclose(tomsg_dfile);
}
__attribute__((format (printf, 1, 2)))
void debugf(const char *restrict format, ...) {
- if (!g_dfile) return;
+ if (!tomsg_dfile) return;
va_list ap;
va_start(ap, format);
- vfprintf(g_dfile, format, ap);
+ vfprintf(tomsg_dfile, format, ap);
va_end(ap);
}