mirror of
https://github.com/weechat/weechat.git
synced 2026-06-30 06:46:38 +02:00
Free color palette structures when exiting WeeChat
This commit is contained in:
@@ -893,7 +893,7 @@ gui_color_palette_build_aliases ()
|
||||
if (!gui_color_hash_palette_alias || !gui_color_list_with_alias
|
||||
|| !gui_color_hash_palette_color)
|
||||
{
|
||||
gui_color_palette_alloc ();
|
||||
gui_color_palette_alloc_structs ();
|
||||
}
|
||||
|
||||
hashtable_remove_all (gui_color_hash_palette_alias);
|
||||
@@ -1050,4 +1050,5 @@ gui_color_end ()
|
||||
{
|
||||
gui_color_free (gui_color[i]);
|
||||
}
|
||||
gui_color_palette_free_structs ();
|
||||
}
|
||||
|
||||
+44
-5
@@ -480,11 +480,32 @@ gui_color_free (struct t_gui_color *color)
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_palette_alloc: allocate hashtables and lists for palette
|
||||
* gui_color_palette_free_value_cb: callback called to free value in hashtable
|
||||
* when item in hashtable is removed
|
||||
*/
|
||||
|
||||
void
|
||||
gui_color_palette_alloc ()
|
||||
gui_color_palette_free_value_cb (struct t_hashtable *hashtable,
|
||||
const void *key, void *value)
|
||||
{
|
||||
struct t_gui_color_palette *color_palette;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) hashtable;
|
||||
(void) key;
|
||||
|
||||
color_palette = (struct t_gui_color_palette *)value;
|
||||
|
||||
if (color_palette)
|
||||
gui_color_palette_free (color_palette);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_palette_alloc_structs: allocate hashtables and lists for palette
|
||||
*/
|
||||
|
||||
void
|
||||
gui_color_palette_alloc_structs ()
|
||||
{
|
||||
if (!gui_color_hash_palette_color)
|
||||
{
|
||||
@@ -493,6 +514,9 @@ gui_color_palette_alloc ()
|
||||
WEECHAT_HASHTABLE_POINTER,
|
||||
NULL,
|
||||
NULL);
|
||||
hashtable_set_pointer (gui_color_hash_palette_color,
|
||||
"callback_free_value",
|
||||
&gui_color_palette_free_value_cb);
|
||||
}
|
||||
if (!gui_color_hash_palette_alias)
|
||||
{
|
||||
@@ -553,7 +577,7 @@ gui_color_palette_add (int number, const char *value)
|
||||
struct t_gui_color_palette *new_color_palette, *ptr_color_palette;
|
||||
char str_number[64];
|
||||
|
||||
gui_color_palette_alloc ();
|
||||
gui_color_palette_alloc_structs ();
|
||||
|
||||
new_color_palette = gui_color_palette_new (number, value);
|
||||
if (!new_color_palette)
|
||||
@@ -585,7 +609,7 @@ gui_color_palette_remove (int number)
|
||||
struct t_gui_color_palette *ptr_color_palette;
|
||||
char str_number[64];
|
||||
|
||||
gui_color_palette_alloc ();
|
||||
gui_color_palette_alloc_structs ();
|
||||
|
||||
snprintf (str_number, sizeof (str_number), "%d", number);
|
||||
ptr_color_palette = hashtable_get (gui_color_hash_palette_color,
|
||||
@@ -613,7 +637,7 @@ gui_color_palette_change (int number, const char *value)
|
||||
struct t_gui_color_palette *ptr_color_palette;
|
||||
char str_number[64];
|
||||
|
||||
gui_color_palette_alloc ();
|
||||
gui_color_palette_alloc_structs ();
|
||||
|
||||
snprintf (str_number, sizeof (str_number), "%d", number);
|
||||
ptr_color_palette = hashtable_get (gui_color_hash_palette_color,
|
||||
@@ -625,3 +649,18 @@ gui_color_palette_change (int number, const char *value)
|
||||
gui_color_palette_add (number, value);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_palette_free_structs: free hashtables and lists for palette
|
||||
*/
|
||||
|
||||
void
|
||||
gui_color_palette_free_structs ()
|
||||
{
|
||||
if (gui_color_hash_palette_color)
|
||||
hashtable_free (gui_color_hash_palette_color);
|
||||
if (gui_color_hash_palette_alias)
|
||||
hashtable_free (gui_color_hash_palette_alias);
|
||||
if (gui_color_list_with_alias)
|
||||
weelist_free (gui_color_list_with_alias);
|
||||
}
|
||||
|
||||
+2
-1
@@ -153,12 +153,13 @@ extern const char *gui_color_get_custom (const char *color_name);
|
||||
extern char *gui_color_decode (const char *string, const char *replacement);
|
||||
extern char *gui_color_string_replace_colors (const char *string);
|
||||
extern void gui_color_free (struct t_gui_color *color);
|
||||
extern void gui_color_palette_alloc ();
|
||||
extern void gui_color_palette_alloc_structs ();
|
||||
extern int gui_color_palette_get_alias (const char *alias);
|
||||
extern struct t_gui_color_palette *gui_color_palette_get (int number);
|
||||
extern void gui_color_palette_add (int number, const char *value);
|
||||
extern void gui_color_palette_remove (int number);
|
||||
extern void gui_color_palette_change (int number, const char *value);
|
||||
extern void gui_color_palette_free_structs ();
|
||||
|
||||
/* color functions (GUI dependent) */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user