about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-07-26 00:40:29 +0100
committerJames Booth <boothj5@gmail.com>2016-07-26 00:40:29 +0100
commitae003e62fbc3cdec698e6c13f7f1e9bf06cbc91f (patch)
tree960cd9698c2bb11c9481f72cc63db4c6f61ca039
parent8602ede65e2a4ef0edfa3a0b4b9c67c4158f15bb (diff)
downloadprofani-tty-ae003e62fbc3cdec698e6c13f7f1e9bf06cbc91f.tar.gz
Remove copied char* in groupchat_log_chat
-rw-r--r--src/log.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/log.c b/src/log.c
index e091f347..43a7be6e 100644
--- a/src/log.c
+++ b/src/log.c
@@ -79,7 +79,7 @@ struct dated_chat_log {
 
 static gboolean _log_roll_needed(struct dated_chat_log *dated_log);
 static struct dated_chat_log* _create_log(const char *const other, const char *const login);
-static struct dated_chat_log* _create_groupchat_log(char *room, const char *const login);
+static struct dated_chat_log* _create_groupchat_log(const char *const room, const char *const login);
 static void _free_chat_log(struct dated_chat_log *dated_log);
 static gboolean _key_equals(void *key1, void *key2);
 static char* _get_log_filename(const char *const other, const char *const login, GDateTime *dt, gboolean create);
@@ -403,20 +403,18 @@ _chat_log_chat(const char *const login, const char *const other, const char *con
 void
 groupchat_log_chat(const gchar *const login, const gchar *const room, const gchar *const nick, const gchar *const msg)
 {
-    char *room_copy = strdup(room);
-    struct dated_chat_log *dated_log = g_hash_table_lookup(groupchat_logs, room_copy);
+    struct dated_chat_log *dated_log = g_hash_table_lookup(groupchat_logs, room);
 
     // no log for room
     if (dated_log == NULL) {
-        dated_log = _create_groupchat_log(room_copy, login);
-        g_hash_table_insert(groupchat_logs, room_copy, dated_log);
+        dated_log = _create_groupchat_log(room, login);
+        g_hash_table_insert(groupchat_logs, strdup(room), dated_log);
 
     // log exists but needs rolling
     } else if (_log_roll_needed(dated_log)) {
-        dated_log = _create_groupchat_log(room_copy, login);
-        g_hash_table_replace(logs, room_copy, dated_log);
+        dated_log = _create_groupchat_log(room, login);
+        g_hash_table_replace(logs, strdup(room), dated_log);
     }
-    free(room_copy);
 
     GDateTime *dt = g_date_time_new_now_local();
 
@@ -515,7 +513,7 @@ _create_log(const char *const other, const char *const login)
 }
 
 static struct dated_chat_log*
-_create_groupchat_log(char *room, const char *const login)
+_create_groupchat_log(const char * const room, const char *const login)
 {
     GDateTime *now = g_date_time_new_now_local();
     char *filename = _get_groupchat_log_filename(room, login, now, TRUE);