mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-22 03:02:06 +03:00
tty: refactoring of color pairs deallocation.
* (tty_color_free_all_tmp): rename to tty_color_free_temp and call g_hash_table_foreach_remove(). * (tty_color_free_all_non_tmp): rename to tty_color_free_all and call g_hash_table_remove_all(). * (tty_color_free_all): remove. * (tty_color_free_condition_cb): rename to tty_color_free_temp_cb and simplify. * (mc_skin_deinit): use changed API. * (edit_free_syntax_rules): likewise. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
2d6d8a477e
commit
5d8399befb
@ -181,8 +181,7 @@ mc_skin_init (const gchar * skin_override, GError ** mcerror)
|
||||
void
|
||||
mc_skin_deinit (void)
|
||||
{
|
||||
tty_color_free_all_tmp ();
|
||||
tty_color_free_all_non_tmp ();
|
||||
tty_color_free_all ();
|
||||
|
||||
MC_PTR_FREE (mc_skin__default.name);
|
||||
g_hash_table_destroy (mc_skin__default.colors);
|
||||
|
@ -84,24 +84,12 @@ mc_color__deinit (tty_color_pair_t * color)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static gboolean
|
||||
tty_color_free_condition_cb (gpointer key, gpointer value, gpointer user_data)
|
||||
tty_color_free_temp_cb (gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
tty_color_lib_pair_t *mc_color_pair = (tty_color_lib_pair_t *) value;
|
||||
gboolean is_temp_color;
|
||||
|
||||
(void) key;
|
||||
(void) user_data;
|
||||
|
||||
is_temp_color = user_data != NULL;
|
||||
return (mc_color_pair->is_temp == is_temp_color);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
tty_color_free_all (gboolean is_temp_color)
|
||||
{
|
||||
g_hash_table_foreach_remove (mc_tty_color__hashtable, tty_color_free_condition_cb,
|
||||
is_temp_color ? GSIZE_TO_POINTER (1) : NULL);
|
||||
return ((tty_color_lib_pair_t *) value)->is_temp;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -216,17 +204,17 @@ tty_try_alloc_color_pair (const tty_color_pair_t * color, gboolean is_temp)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
tty_color_free_all_tmp (void)
|
||||
tty_color_free_temp (void)
|
||||
{
|
||||
tty_color_free_all (TRUE);
|
||||
g_hash_table_foreach_remove (mc_tty_color__hashtable, tty_color_free_temp_cb, NULL);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
tty_color_free_all_non_tmp (void)
|
||||
tty_color_free_all (void)
|
||||
{
|
||||
tty_color_free_all (FALSE);
|
||||
g_hash_table_remove_all (mc_tty_color__hashtable);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -43,8 +43,8 @@ void tty_colors_done (void);
|
||||
gboolean tty_use_colors (void);
|
||||
int tty_try_alloc_color_pair (const tty_color_pair_t * color, gboolean is_temp);
|
||||
|
||||
void tty_color_free_all_tmp (void);
|
||||
void tty_color_free_all_non_tmp (void);
|
||||
void tty_color_free_temp (void);
|
||||
void tty_color_free_all (void);
|
||||
|
||||
void tty_setcolor (int color);
|
||||
void tty_lowlevel_setcolor (int color);
|
||||
|
@ -1482,7 +1482,7 @@ edit_free_syntax_rules (WEdit * edit)
|
||||
g_ptr_array_free (edit->rules, TRUE);
|
||||
edit->rules = NULL;
|
||||
g_clear_slist (&edit->syntax_marker, g_free);
|
||||
tty_color_free_all_tmp ();
|
||||
tty_color_free_temp ();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
Loading…
Reference in New Issue
Block a user