talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit b52781b8c44a3796d6f5c0b8d33a386938cf6164
parent 6596986bb6f093716c38f9af25f5771a88b6747a
Author: Jonathan Boeing <jonathan@claws-mail.org>
Date:   Mon, 27 Sep 2021 01:37:12 -0700

Remove cm_mutex_new/_free wrappers

Diffstat:
Msrc/common/utils.c | 11-----------
Msrc/common/utils.h | 3---
Msrc/compose.c | 22+++++++++++-----------
Msrc/compose.h | 2+-
Msrc/prefs_account.c | 26++++++++++++--------------
5 files changed, 24 insertions(+), 40 deletions(-)

diff --git a/src/common/utils.c b/src/common/utils.c @@ -4441,17 +4441,6 @@ size_t fast_strftime(gchar *buf, gint buflen, const gchar *format, struct tm *lt #define WEXITSTATUS(x) (x) #endif -GMutex *cm_mutex_new(void) { - GMutex *m = g_new0(GMutex, 1); - g_mutex_init(m); - return m; -} - -void cm_mutex_free(GMutex *mutex) { - g_mutex_clear(mutex); - g_free(mutex); -} - static gchar *canonical_list_to_file(GSList *list) { GString *result = g_string_new(NULL); diff --git a/src/common/utils.h b/src/common/utils.h @@ -524,9 +524,6 @@ gboolean file_is_email(const gchar *filename); gboolean sc_g_list_bigger(GList *list, gint max); gboolean sc_g_slist_bigger(GSList *list, gint max); -GMutex *cm_mutex_new(void); -void cm_mutex_free(GMutex *mutex); - int cm_canonicalize_filename(const gchar *filename, gchar **canonical_name); guchar *g_base64_decode_zero(const gchar *text, gsize *out_len); diff --git a/src/compose.c b/src/compose.c @@ -7818,7 +7818,7 @@ static Compose *compose_create(PrefsAccount *account, compose->account = account; compose->folder = folder; - compose->mutex = cm_mutex_new(); + g_mutex_init(&compose->mutex); compose->set_cursor_pos = -1; window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "compose"); @@ -9242,7 +9242,7 @@ static void compose_destroy(Compose *compose) gtk_widget_destroy(compose->window); toolbar_destroy(compose->toolbar); g_free(compose->toolbar); - cm_mutex_free(compose->mutex); + g_mutex_clear(&compose->mutex); g_free(compose); } @@ -10320,7 +10320,7 @@ gboolean compose_draft (gpointer data, guint action) draft = account_get_special_folder(compose->account, F_DRAFT); cm_return_val_if_fail(draft != NULL, FALSE); - if (!g_mutex_trylock(compose->mutex)) { + if (!g_mutex_trylock(&compose->mutex)) { /* we don't want to lock the mutex once it's available, * because as the only other part of compose.c locking * it is compose_close - which means once unlocked, @@ -10461,12 +10461,12 @@ warn_err: FALSE, NULL, ALERT_QUESTION); if (val == G_ALERTALTERNATE) { lock = FALSE; - g_mutex_unlock(compose->mutex); /* must be done before closing */ + g_mutex_unlock(&compose->mutex); /* must be done before closing */ compose_close(compose); return TRUE; } else { lock = FALSE; - g_mutex_unlock(compose->mutex); /* must be done before closing */ + g_mutex_unlock(&compose->mutex); /* must be done before closing */ return FALSE; } } @@ -10501,7 +10501,7 @@ warn_err: if (action == COMPOSE_QUIT_EDITING || action == COMPOSE_DRAFT_FOR_EXIT) { lock = FALSE; - g_mutex_unlock(compose->mutex); /* must be done before closing */ + g_mutex_unlock(&compose->mutex); /* must be done before closing */ compose_close(compose); return TRUE; } else { @@ -10567,7 +10567,7 @@ warn_err: } unlock: lock = FALSE; - g_mutex_unlock(compose->mutex); + g_mutex_unlock(&compose->mutex); return TRUE; } @@ -10744,7 +10744,7 @@ static void compose_close_cb(GtkAction *action, gpointer data) if (compose->modified) { gboolean reedit = (compose->rmode == COMPOSE_REEDIT); - if (!g_mutex_trylock(compose->mutex)) { + if (!g_mutex_trylock(&compose->mutex)) { /* we don't want to lock the mutex once it's available, * because as the only other part of compose.c locking * it is compose_close - which means once unlocked, @@ -10763,7 +10763,7 @@ static void compose_close_cb(GtkAction *action, gpointer data) _("_Don't save"), _("_Save to Drafts"), GTK_STOCK_CANCEL, ALERTFOCUS_SECOND); } - g_mutex_unlock(compose->mutex); + g_mutex_unlock(&compose->mutex); switch (val) { case G_ALERTDEFAULT: if (compose_can_autosave(compose) && !reedit) @@ -12128,7 +12128,7 @@ gboolean compose_close(Compose *compose) cm_return_val_if_fail(compose, FALSE); - if (!g_mutex_trylock(compose->mutex)) { + if (!g_mutex_trylock(&compose->mutex)) { /* we have to wait for the (possibly deferred by auto-save) * drafting to be done, before destroying the compose under * it. */ @@ -12152,7 +12152,7 @@ gboolean compose_close(Compose *compose) prefs_common.compose_x = x; prefs_common.compose_y = y; } - g_mutex_unlock(compose->mutex); + g_mutex_unlock(&compose->mutex); compose_destroy(compose); return FALSE; } diff --git a/src/compose.h b/src/compose.h @@ -244,7 +244,7 @@ struct _Compose GtkTextTag *uri_tag; gboolean automatic_break; - GMutex *mutex; + GMutex mutex; gint close_timeout_tag; gchar *orig_charset; gint set_cursor_pos; diff --git a/src/prefs_account.c b/src/prefs_account.c @@ -4259,8 +4259,8 @@ static gboolean sslcert_get_client_cert_hook(gpointer source, gpointer data) } struct GetPassData { - GCond *cond; - GMutex* mutex; + GCond cond; + GMutex mutex; gchar **pass; }; @@ -4268,30 +4268,28 @@ struct GetPassData { static gboolean do_get_pass(gpointer data) { struct GetPassData *pass_data = (struct GetPassData *)data; - g_mutex_lock(pass_data->mutex); + g_mutex_lock(&pass_data->mutex); *(pass_data->pass) = input_dialog_query_password("the PKCS12 client certificate", NULL); - g_cond_signal(pass_data->cond); - g_mutex_unlock(pass_data->mutex); + g_cond_signal(&pass_data->cond); + g_mutex_unlock(&pass_data->mutex); return FALSE; } static gboolean sslcert_get_password(gpointer source, gpointer data) { struct GetPassData pass_data; /* do complicated stuff to be able to call GTK from the mainloop */ - pass_data.cond = g_new0(GCond, 1); - g_cond_init(pass_data.cond); - pass_data.mutex = cm_mutex_new(); + g_cond_init(&pass_data.cond); + g_mutex_init(&pass_data.mutex); pass_data.pass = (gchar **)source; - g_mutex_lock(pass_data.mutex); + g_mutex_lock(&pass_data.mutex); g_idle_add(do_get_pass, &pass_data); - g_cond_wait(pass_data.cond, pass_data.mutex); - g_cond_clear(pass_data.cond); - g_free(pass_data.cond); - g_mutex_unlock(pass_data.mutex); - cm_mutex_free(pass_data.mutex); + g_cond_wait(&pass_data.cond, &pass_data.mutex); + g_cond_clear(&pass_data.cond); + g_mutex_unlock(&pass_data.mutex); + g_mutex_clear(&pass_data.mutex); return TRUE; }