From f55272ecde857c116f97a3195f3abd1df3be4b86 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 2 May 2011 20:57:28 -0400 Subject: [PATCH] Add hb_mutex_free() and use it Based on patch by Bradley Grainger. --- src/hb-blob.cc | 1 + src/hb-private.hh | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/hb-blob.cc b/src/hb-blob.cc index db12758..bcbfa34 100644 --- a/src/hb-blob.cc +++ b/src/hb-blob.cc @@ -158,6 +158,7 @@ hb_blob_destroy (hb_blob_t *blob) if (!hb_object_destroy (blob)) return; _hb_blob_destroy_user_data (blob); + hb_mutex_free (blob->lock); free (blob); } diff --git a/src/hb-private.hh b/src/hb-private.hh index 445f602..a45fece 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -234,10 +234,11 @@ typedef volatile int hb_atomic_int_t; typedef GStaticMutex hb_mutex_t; #define HB_MUTEX_INIT G_STATIC_MUTEX_INIT -#define hb_mutex_init(M) g_static_mutex_init (&M) -#define hb_mutex_lock(M) g_static_mutex_lock (&M) -#define hb_mutex_trylock(M) g_static_mutex_trylock (&M) -#define hb_mutex_unlock(M) g_static_mutex_unlock (&M) +#define hb_mutex_init(M) g_static_mutex_init (&(M)) +#define hb_mutex_lock(M) g_static_mutex_lock (&(M)) +#define hb_mutex_trylock(M) g_static_mutex_trylock (&(M)) +#define hb_mutex_unlock(M) g_static_mutex_unlock (&(M)) +#define hb_mutex_free(M) g_static_mutex_free (&(M)) #else @@ -257,10 +258,11 @@ typedef volatile int hb_atomic_int_t; typedef volatile int hb_mutex_t; #define HB_MUTEX_INIT 0 -#define hb_mutex_init(M) HB_STMT_START { (M) = 0; } HB_STMT_END -#define hb_mutex_lock(M) HB_STMT_START { (M) = 1; } HB_STMT_END +#define hb_mutex_init(M) ((void) ((M) = 0)) +#define hb_mutex_lock(M) ((void) ((M) = 1)) #define hb_mutex_trylock(M) ((M) = 1, 1) -#define hb_mutex_unlock(M) HB_STMT_START { (M) = 0; } HB_STMT_END +#define hb_mutex_unlock(M) ((void) ((M) = 0)) +#define hb_mutex_free(M) ((void) ((M) = 2)) #endif -- 2.7.4