Move object mutext into the user-data array
We are not using it for anything lse it seems.
diff --git a/src/hb-common.cc b/src/hb-common.cc
index 33a514d..9422555 100644
--- a/src/hb-common.cc
+++ b/src/hb-common.cc
@@ -363,8 +363,7 @@
hb_user_data_array_t::set (hb_user_data_key_t *key,
void * data,
hb_destroy_func_t destroy,
- hb_bool_t replace,
- hb_mutex_t &lock)
+ hb_bool_t replace)
{
if (!key)
return false;
@@ -382,20 +381,13 @@
}
void *
-hb_user_data_array_t::get (hb_user_data_key_t *key,
- hb_mutex_t &lock)
+hb_user_data_array_t::get (hb_user_data_key_t *key)
{
hb_user_data_item_t item = {NULL };
return items.find (key, &item, lock) ? item.data : NULL;
}
-void
-hb_user_data_array_t::finish (hb_mutex_t &lock)
-{
- items.finish (lock);
-}
-
/* hb_version */
diff --git a/src/hb-object-private.hh b/src/hb-object-private.hh
index 0499226..8a9ae34 100644
--- a/src/hb-object-private.hh
+++ b/src/hb-object-private.hh
@@ -65,7 +65,7 @@
/* user_data */
-#define HB_USER_DATA_ARRAY_INIT {HB_LOCKABLE_SET_INIT}
+#define HB_USER_DATA_ARRAY_INIT {HB_MUTEX_INIT, HB_LOCKABLE_SET_INIT}
struct hb_user_data_array_t
{
/* TODO Add tracing. */
@@ -81,20 +81,19 @@
void finish (void) { if (destroy) destroy (data); }
};
+ hb_mutex_t lock;
hb_lockable_set_t<hb_user_data_item_t, hb_mutex_t> items;
- inline void init (void) { items.init (); }
+ inline void init (void) { lock.init (); items.init (); }
HB_INTERNAL bool set (hb_user_data_key_t *key,
void * data,
hb_destroy_func_t destroy,
- hb_bool_t replace,
- hb_mutex_t &lock);
+ hb_bool_t replace);
- HB_INTERNAL void *get (hb_user_data_key_t *key,
- hb_mutex_t &lock);
+ HB_INTERNAL void *get (hb_user_data_key_t *key);
- HB_INTERNAL void finish (hb_mutex_t &lock);
+ inline void finish (void) { items.finish (lock); lock.finish (); }
};
@@ -103,10 +102,9 @@
struct hb_object_header_t
{
hb_reference_count_t ref_count;
- hb_mutex_t mutex;
hb_user_data_array_t user_data;
-#define HB_OBJECT_HEADER_STATIC {HB_REFERENCE_COUNT_INVALID, HB_MUTEX_INIT, HB_USER_DATA_ARRAY_INIT}
+#define HB_OBJECT_HEADER_STATIC {HB_REFERENCE_COUNT_INVALID, HB_USER_DATA_ARRAY_INIT}
static inline void *create (unsigned int size) {
hb_object_header_t *obj = (hb_object_header_t *) calloc (1, size);
@@ -119,7 +117,6 @@
inline void init (void) {
ref_count.init (1);
- mutex.init ();
user_data.init ();
}
@@ -140,8 +137,7 @@
return false;
ref_count.finish (); /* Do this before user_data */
- user_data.finish (mutex);
- mutex.finish ();
+ user_data.finish ();
return true;
}
@@ -153,14 +149,14 @@
if (unlikely (!this || this->is_inert ()))
return false;
- return user_data.set (key, data, destroy_func, replace, mutex);
+ return user_data.set (key, data, destroy_func, replace);
}
inline void *get_user_data (hb_user_data_key_t *key) {
if (unlikely (!this || this->is_inert ()))
return NULL;
- return user_data.get (key, mutex);
+ return user_data.get (key);
}
inline void trace (const char *function) const {