summaryrefslogtreecommitdiff
path: root/src/irc
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2000-05-18 08:46:56 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2000-05-18 08:46:56 +0000
commitae25925a1fdceeddff25076b5ff557e14f1aa4cb (patch)
tree7c417ca056f58f2720c41c1493f41ad3ed3d4fc7 /src/irc
parenta0aa6493682fc7b12a83352857abd3697a1ea677 (diff)
downloadirssi-ae25925a1fdceeddff25076b5ff557e14f1aa4cb.zip
Some logging fixes. Flood checking had a memory leak. Query had a small
memory leak. Text buffer fixes. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@226 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/irc')
-rw-r--r--src/irc/core/ignore.c1
-rw-r--r--src/irc/core/irc-log.c19
-rw-r--r--src/irc/core/query.c1
-rw-r--r--src/irc/flood/flood.c28
4 files changed, 30 insertions, 19 deletions
diff --git a/src/irc/core/ignore.c b/src/irc/core/ignore.c
index 76c1d368..ac4f67ca 100644
--- a/src/irc/core/ignore.c
+++ b/src/irc/core/ignore.c
@@ -251,7 +251,6 @@ static void read_ignores(void)
IGNORE_REC *rec;
CONFIG_NODE *node;
GSList *tmp;
- char *str;
while (ignores != NULL)
ignore_destroy(ignores->data);
diff --git a/src/irc/core/irc-log.c b/src/irc/core/irc-log.c
index accf6014..9773a29a 100644
--- a/src/irc/core/irc-log.c
+++ b/src/irc/core/irc-log.c
@@ -40,20 +40,15 @@ static void event_away(const char *data, IRC_SERVER_REC *server)
if (level == 0) return;
log = log_find(fname);
- if (log != NULL) {
- /* awaylog already created */
- if (log->handle == -1) {
- /* ..but not open, open it. */
- log_start_logging(log);
- }
- return;
- }
-
- log = log_create_rec(fname, level, NULL);
- if (log != NULL) {
+ if (log == NULL) {
+ log = log_create_rec(fname, level, NULL);
log->temp = TRUE;
log_update(log);
- log_start_logging(log);
+ }
+
+ if (!log_start_logging(log)) {
+ /* creating log file failed? close it. */
+ log_close(log);
}
}
diff --git a/src/irc/core/query.c b/src/irc/core/query.c
index cce333af..4f85b3f1 100644
--- a/src/irc/core/query.c
+++ b/src/irc/core/query.c
@@ -63,6 +63,7 @@ void query_destroy(QUERY_REC *query)
signal_emit("query destroyed", 1, query);
MODULE_DATA_DEINIT(query);
+ g_free_not_null(query->address);
g_free(query->nick);
g_free(query->server_tag);
g_free(query);
diff --git a/src/irc/flood/flood.c b/src/irc/flood/flood.c
index b1648f5f..b9617157 100644
--- a/src/irc/flood/flood.c
+++ b/src/irc/flood/flood.c
@@ -46,7 +46,7 @@ typedef struct {
static int flood_tag;
static int flood_max_msgs, flood_timecheck;
-static int flood_hash_deinit(const char *key, FLOOD_REC *flood, gpointer nowp)
+static int flood_hash_check_remove(const char *key, FLOOD_REC *flood, gpointer nowp)
{
GSList *tmp, *next;
time_t now;
@@ -59,8 +59,11 @@ static int flood_hash_deinit(const char *key, FLOOD_REC *flood, gpointer nowp)
FLOOD_ITEM_REC *rec = tmp->data;
next = tmp->next;
- if (now-rec->first >= flood_timecheck)
+ if (now-rec->first >= flood_timecheck) {
flood->items = g_slist_remove(flood->items, rec);
+ g_free(rec->target);
+ g_free(rec);
+ }
}
if (flood->items != NULL)
@@ -83,7 +86,7 @@ static int flood_timeout(void)
IRC_SERVER_REC *rec = tmp->data;
mserver = MODULE_DATA(rec);
- g_hash_table_foreach_remove(mserver->floodlist, (GHRFunc) flood_hash_deinit, GINT_TO_POINTER((int) now));
+ g_hash_table_foreach_remove(mserver->floodlist, (GHRFunc) flood_hash_check_remove, GINT_TO_POINTER((int) now));
}
return 1;
}
@@ -101,6 +104,21 @@ static void flood_init_server(IRC_SERVER_REC *server)
rec->floodlist = g_hash_table_new((GHashFunc) g_istr_hash, (GCompareFunc) g_istr_equal);
}
+static void flood_hash_destroy(const char *key, FLOOD_REC *flood)
+{
+ while (flood->items != NULL) {
+ FLOOD_ITEM_REC *rec = flood->items->data;
+
+ g_free(rec->target);
+ g_free(rec);
+
+ flood->items = g_slist_remove(flood->items, rec);
+ }
+
+ g_free(flood->nick);
+ g_free(flood);
+}
+
/* Deinitialize flood protection */
static void flood_deinit_server(IRC_SERVER_REC *server)
{
@@ -112,9 +130,7 @@ static void flood_deinit_server(IRC_SERVER_REC *server)
if (mserver != NULL && mserver->floodlist != NULL) {
flood_timecheck = 0;
- g_hash_table_freeze(mserver->floodlist);
- g_hash_table_foreach(mserver->floodlist, (GHFunc) flood_hash_deinit, NULL);
- g_hash_table_thaw(mserver->floodlist);
+ g_hash_table_foreach(mserver->floodlist, (GHFunc) flood_hash_destroy, NULL);
g_hash_table_destroy(mserver->floodlist);
}
g_free(mserver);