mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Merge pull request #84 from ailin-nemui/ignore-leak
avoid memory leak in ignore cache
This commit is contained in:
commit
af5feb16be
@ -6,7 +6,7 @@
|
|||||||
#define IRSSI_GLOBAL_CONFIG "irssi.conf" /* config file name in /etc/ */
|
#define IRSSI_GLOBAL_CONFIG "irssi.conf" /* config file name in /etc/ */
|
||||||
#define IRSSI_HOME_CONFIG "config" /* config file name in ~/.irssi/ */
|
#define IRSSI_HOME_CONFIG "config" /* config file name in ~/.irssi/ */
|
||||||
|
|
||||||
#define IRSSI_ABI_VERSION 48
|
#define IRSSI_ABI_VERSION 49
|
||||||
|
|
||||||
#define DEFAULT_SERVER_ADD_PORT 6667
|
#define DEFAULT_SERVER_ADD_PORT 6667
|
||||||
#define DEFAULT_SERVER_ADD_TLS_PORT 6697
|
#define DEFAULT_SERVER_ADD_TLS_PORT 6697
|
||||||
|
@ -490,6 +490,11 @@ static void read_ignores(void)
|
|||||||
nickmatch_rebuild(nickmatch);
|
nickmatch_rebuild(nickmatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void free_cache_matches(GSList *matches)
|
||||||
|
{
|
||||||
|
g_slist_free(matches);
|
||||||
|
}
|
||||||
|
|
||||||
static void ignore_nick_cache(GHashTable *list, CHANNEL_REC *channel,
|
static void ignore_nick_cache(GHashTable *list, CHANNEL_REC *channel,
|
||||||
NICK_REC *nick)
|
NICK_REC *nick)
|
||||||
{
|
{
|
||||||
@ -520,7 +525,7 @@ static void ignore_nick_cache(GHashTable *list, CHANNEL_REC *channel,
|
|||||||
void ignore_init(void)
|
void ignore_init(void)
|
||||||
{
|
{
|
||||||
ignores = NULL;
|
ignores = NULL;
|
||||||
nickmatch = nickmatch_init(ignore_nick_cache);
|
nickmatch = nickmatch_init(ignore_nick_cache, (GDestroyNotify) free_cache_matches);
|
||||||
time_tag = g_timeout_add(1000, (GSourceFunc) unignore_timeout, NULL);
|
time_tag = g_timeout_add(1000, (GSourceFunc) unignore_timeout, NULL);
|
||||||
|
|
||||||
read_ignores();
|
read_ignores();
|
||||||
|
@ -28,12 +28,13 @@
|
|||||||
|
|
||||||
static GSList *lists;
|
static GSList *lists;
|
||||||
|
|
||||||
NICKMATCH_REC *nickmatch_init(NICKMATCH_REBUILD_FUNC func)
|
NICKMATCH_REC *nickmatch_init(NICKMATCH_REBUILD_FUNC func, GDestroyNotify value_destroy_func)
|
||||||
{
|
{
|
||||||
NICKMATCH_REC *rec;
|
NICKMATCH_REC *rec;
|
||||||
|
|
||||||
rec = g_new0(NICKMATCH_REC, 1);
|
rec = g_new0(NICKMATCH_REC, 1);
|
||||||
rec->func = func;
|
rec->func = func;
|
||||||
|
rec->value_destroy_func = value_destroy_func;
|
||||||
|
|
||||||
lists = g_slist_append(lists, rec);
|
lists = g_slist_append(lists, rec);
|
||||||
return rec;
|
return rec;
|
||||||
@ -43,8 +44,9 @@ void nickmatch_deinit(NICKMATCH_REC *rec)
|
|||||||
{
|
{
|
||||||
lists = g_slist_remove(lists, rec);
|
lists = g_slist_remove(lists, rec);
|
||||||
|
|
||||||
g_hash_table_destroy(rec->nicks);
|
if (rec->nicks != NULL)
|
||||||
g_free(rec);
|
g_hash_table_destroy(rec->nicks);
|
||||||
|
g_free(rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nickmatch_check_channel(CHANNEL_REC *channel, NICKMATCH_REC *rec)
|
static void nickmatch_check_channel(CHANNEL_REC *channel, NICKMATCH_REC *rec)
|
||||||
@ -65,8 +67,8 @@ void nickmatch_rebuild(NICKMATCH_REC *rec)
|
|||||||
if (rec->nicks != NULL)
|
if (rec->nicks != NULL)
|
||||||
g_hash_table_destroy(rec->nicks);
|
g_hash_table_destroy(rec->nicks);
|
||||||
|
|
||||||
rec->nicks = g_hash_table_new((GHashFunc) g_direct_hash,
|
rec->nicks = g_hash_table_new_full((GHashFunc) g_direct_hash, (GCompareFunc) g_direct_equal,
|
||||||
(GCompareFunc) g_direct_equal);
|
NULL, (GDestroyNotify) rec->value_destroy_func);
|
||||||
|
|
||||||
g_slist_foreach(channels, (GFunc) nickmatch_check_channel, rec);
|
g_slist_foreach(channels, (GFunc) nickmatch_check_channel, rec);
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,10 @@ typedef void (*NICKMATCH_REBUILD_FUNC) (GHashTable *list,
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
GHashTable *nicks;
|
GHashTable *nicks;
|
||||||
NICKMATCH_REBUILD_FUNC func;
|
NICKMATCH_REBUILD_FUNC func;
|
||||||
|
GDestroyNotify value_destroy_func;
|
||||||
} NICKMATCH_REC;
|
} NICKMATCH_REC;
|
||||||
|
|
||||||
NICKMATCH_REC *nickmatch_init(NICKMATCH_REBUILD_FUNC func);
|
NICKMATCH_REC *nickmatch_init(NICKMATCH_REBUILD_FUNC func, GDestroyNotify value_destroy_func);
|
||||||
void nickmatch_deinit(NICKMATCH_REC *rec);
|
void nickmatch_deinit(NICKMATCH_REC *rec);
|
||||||
|
|
||||||
/* Calls rebuild function for all nicks in all channels.
|
/* Calls rebuild function for all nicks in all channels.
|
||||||
|
@ -793,7 +793,7 @@ void hilight_text_init(void)
|
|||||||
|
|
||||||
read_settings();
|
read_settings();
|
||||||
|
|
||||||
nickmatch = nickmatch_init(hilight_nick_cache);
|
nickmatch = nickmatch_init(hilight_nick_cache, NULL);
|
||||||
read_hilight_config();
|
read_hilight_config();
|
||||||
|
|
||||||
signal_add_first("print text", (SIGNAL_FUNC) sig_print_text);
|
signal_add_first("print text", (SIGNAL_FUNC) sig_print_text);
|
||||||
|
Loading…
Reference in New Issue
Block a user