From 61b283f2e9a8343267ffd0280bacc1369075b763 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 13 Jul 2020 22:08:04 +0200 Subject: weechat: Proper namespacing of symbols Symbol clash in dynamic libraries is a thing. --- weechat/debug.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'weechat/debug.c') 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); } -- cgit v1.2.3-54-g00ecf