diff options
author | James Booth <boothj5@gmail.com> | 2012-07-23 01:27:58 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-07-23 01:27:58 +0100 |
commit | 4dcec36ef328cd1d2ee0b23fc46607db13091d59 (patch) | |
tree | 5eae0a14085473004f424924146162a1c74502ee /src | |
parent | 45b2944da7b0cb8d819f4a8158d7ae714d86784b (diff) | |
download | profani-tty-4dcec36ef328cd1d2ee0b23fc46607db13091d59.tar.gz |
Close logs on exit
Diffstat (limited to 'src')
-rw-r--r-- | src/chat_log.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/chat_log.c b/src/chat_log.c index becaee5e..62e88a8f 100644 --- a/src/chat_log.c +++ b/src/chat_log.c @@ -31,7 +31,7 @@ static GHashTable *logs; static GTimeZone *tz; -//static void _close_file(gpointer key, gpointer value, gpointer user_data); +static void _close_file(gpointer key, gpointer value, gpointer user_data); void chat_log_init(void) { @@ -42,7 +42,7 @@ void chat_log_init(void) void chat_log_chat(const char * const login, char *other, const char * const msg, chat_log_direction_t direction) { - gpointer *logpp = g_hash_table_lookup(logs, other); + gpointer logpp = g_hash_table_lookup(logs, other); FILE *logp; if (logpp == NULL) { @@ -58,9 +58,9 @@ void chat_log_chat(const char * const login, char *other, logp = fopen(log_file->str, "a"); g_string_free(log_file, TRUE); - g_hash_table_insert(logs, other, &logp); + g_hash_table_insert(logs, other, logp); } else { - logp = *logpp; + logp = (FILE *) logpp; } GDateTime *dt = g_date_time_new_now(tz); @@ -78,11 +78,11 @@ void chat_log_chat(const char * const login, char *other, void chat_log_close(void) { -// g_hash_table_foreach(logs, (GHFunc) _close_file, NULL); + g_hash_table_foreach(logs, (GHFunc) _close_file, NULL); g_time_zone_unref(tz); } -//static void _close_file(gpointer key, gpointer value, gpointer user_data) -//{ -// fclose(value); -//} +static void _close_file(gpointer key, gpointer value, gpointer user_data) +{ + fclose(value); +} |