[HarfBuzz] harfbuzz: Branch 'master'

Behdad Esfahbod behdad at kemper.freedesktop.org
Wed Oct 11 13:51:49 UTC 2017


 src/hb-blob.cc     |    8 +++++++-
 src/hb-coretext.cc |   10 ++++++++--
 src/hb-face.cc     |    6 ++++--
 src/hb-ft.cc       |   20 +++++++++++---------
 src/hb-glib.cc     |    9 ++++++++-
 src/hb-ot-font.cc  |    6 ++++--
 6 files changed, 42 insertions(+), 17 deletions(-)

New commits:
commit e1b6d923021f68713784e2fd68f631c053ef3497
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Oct 11 15:51:31 2017 +0200

    Remove cast of functions to (hb_destroy_func_t)
    
    Fixes https://github.com/behdad/harfbuzz/issues/474

diff --git a/src/hb-blob.cc b/src/hb-blob.cc
index fb48f03c..41e99da0 100644
--- a/src/hb-blob.cc
+++ b/src/hb-blob.cc
@@ -128,6 +128,12 @@ hb_blob_create (const char        *data,
   return blob;
 }
 
+static void
+_hb_blob_destroy (void *data)
+{
+  hb_blob_destroy ((hb_blob_t *) data);
+}
+
 /**
  * hb_blob_create_sub_blob:
  * @parent: Parent blob.
@@ -164,7 +170,7 @@ hb_blob_create_sub_blob (hb_blob_t    *parent,
 			 MIN (length, parent->length - offset),
 			 HB_MEMORY_MODE_READONLY,
 			 hb_blob_reference (parent),
-			 (hb_destroy_func_t) hb_blob_destroy);
+			 _hb_blob_destroy);
 
   return blob;
 }
diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index c24ce70c..d899737d 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -64,10 +64,16 @@ reference_table  (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data)
 			 release_table_data);
 }
 
+static void
+_hb_cg_font_release (void *data)
+{
+  CGFontRelease ((CGFontRef) data);
+}
+
 hb_face_t *
 hb_coretext_face_create (CGFontRef cg_font)
 {
-  return hb_face_create_for_tables (reference_table, CGFontRetain (cg_font), (hb_destroy_func_t) CGFontRelease);
+  return hb_face_create_for_tables (reference_table, CGFontRetain (cg_font), _hb_cg_font_release);
 }
 
 
@@ -116,7 +122,7 @@ static CGFontRef
 create_cg_font (hb_face_t *face)
 {
   CGFontRef cg_font = NULL;
-  if (face->destroy == (hb_destroy_func_t) CGFontRelease)
+  if (face->destroy == _hb_cg_font_release)
   {
     cg_font = CGFontRetain ((CGFontRef) face->user_data);
   }
diff --git a/src/hb-face.cc b/src/hb-face.cc
index d7d736d7..0f90b59f 100644
--- a/src/hb-face.cc
+++ b/src/hb-face.cc
@@ -118,8 +118,10 @@ _hb_face_for_data_closure_create (hb_blob_t *blob, unsigned int index)
 }
 
 static void
-_hb_face_for_data_closure_destroy (hb_face_for_data_closure_t *closure)
+_hb_face_for_data_closure_destroy (void *data)
 {
+  hb_face_for_data_closure_t *closure = (hb_face_for_data_closure_t *) data;
+
   hb_blob_destroy (closure->blob);
   free (closure);
 }
@@ -169,7 +171,7 @@ hb_face_create (hb_blob_t    *blob,
 
   face = hb_face_create_for_tables (_hb_face_for_data_reference_table,
 				    closure,
-				    (hb_destroy_func_t) _hb_face_for_data_closure_destroy);
+				    _hb_face_for_data_closure_destroy);
 
   face->index = index;
 
diff --git a/src/hb-ft.cc b/src/hb-ft.cc
index 492992ee..c560b219 100644
--- a/src/hb-ft.cc
+++ b/src/hb-ft.cc
@@ -95,14 +95,16 @@ _hb_ft_font_create (FT_Face ft_face, bool symbol, bool unref)
 }
 
 static void
-_hb_ft_face_destroy (FT_Face ft_face)
+_hb_ft_face_destroy (void *data)
 {
-  FT_Done_Face (ft_face);
+  FT_Done_Face ((FT_Face) data);
 }
 
 static void
-_hb_ft_font_destroy (hb_ft_font_t *ft_font)
+_hb_ft_font_destroy (void *data)
 {
+  hb_ft_font_t *ft_font = (hb_ft_font_t *) data;
+
   if (ft_font->unref)
     _hb_ft_face_destroy (ft_font->ft_face);
 
@@ -124,7 +126,7 @@ hb_ft_font_set_load_flags (hb_font_t *font, int load_flags)
   if (font->immutable)
     return;
 
-  if (font->destroy != (hb_destroy_func_t) _hb_ft_font_destroy)
+  if (font->destroy != _hb_ft_font_destroy)
     return;
 
   hb_ft_font_t *ft_font = (hb_ft_font_t *) font->user_data;
@@ -144,7 +146,7 @@ hb_ft_font_set_load_flags (hb_font_t *font, int load_flags)
 int
 hb_ft_font_get_load_flags (hb_font_t *font)
 {
-  if (font->destroy != (hb_destroy_func_t) _hb_ft_font_destroy)
+  if (font->destroy != _hb_ft_font_destroy)
     return 0;
 
   const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font->user_data;
@@ -155,7 +157,7 @@ hb_ft_font_get_load_flags (hb_font_t *font)
 FT_Face
 hb_ft_font_get_face (hb_font_t *font)
 {
-  if (font->destroy != (hb_destroy_func_t) _hb_ft_font_destroy)
+  if (font->destroy != _hb_ft_font_destroy)
     return NULL;
 
   const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font->user_data;
@@ -474,7 +476,7 @@ retry:
   hb_font_set_funcs (font,
 		     funcs,
 		     _hb_ft_font_create (ft_face, symbol, unref),
-		     (hb_destroy_func_t) _hb_ft_font_destroy);
+		     _hb_ft_font_destroy);
 }
 
 
@@ -553,7 +555,7 @@ hb_face_t *
 hb_ft_face_create_referenced (FT_Face ft_face)
 {
   FT_Reference_Face (ft_face);
-  return hb_ft_face_create (ft_face, (hb_destroy_func_t) _hb_ft_face_destroy);
+  return hb_ft_face_create (ft_face, _hb_ft_face_destroy);
 }
 
 static void
@@ -655,7 +657,7 @@ hb_font_t *
 hb_ft_font_create_referenced (FT_Face ft_face)
 {
   FT_Reference_Face (ft_face);
-  return hb_ft_font_create (ft_face, (hb_destroy_func_t) _hb_ft_face_destroy);
+  return hb_ft_font_create (ft_face, _hb_ft_face_destroy);
 }
 
 
diff --git a/src/hb-glib.cc b/src/hb-glib.cc
index 2b91b5b6..8b499558 100644
--- a/src/hb-glib.cc
+++ b/src/hb-glib.cc
@@ -383,6 +383,13 @@ hb_glib_get_unicode_funcs (void)
 }
 
 #if GLIB_CHECK_VERSION(2,31,10)
+
+static void
+_hb_g_bytes_unref (void *data)
+{
+  g_bytes_unref ((GBytes *) data);
+}
+
 /**
  * hb_glib_blob_create:
  *
@@ -397,6 +404,6 @@ hb_glib_blob_create (GBytes *gbytes)
 			 size,
 			 HB_MEMORY_MODE_READONLY,
 			 g_bytes_ref (gbytes),
-			 (hb_destroy_func_t) g_bytes_unref);
+			 _hb_g_bytes_unref);
 }
 #endif
diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc
index d3251caf..a56f4c07 100644
--- a/src/hb-ot-font.cc
+++ b/src/hb-ot-font.cc
@@ -458,8 +458,10 @@ _hb_ot_font_create (hb_face_t *face)
 }
 
 static void
-_hb_ot_font_destroy (hb_ot_font_t *ot_font)
+_hb_ot_font_destroy (void *data)
 {
+  hb_ot_font_t *ot_font = (hb_ot_font_t *) data;
+
   ot_font->cmap.fini ();
   ot_font->h_metrics.fini ();
   ot_font->v_metrics.fini ();
@@ -627,5 +629,5 @@ hb_ot_font_set_funcs (hb_font_t *font)
   hb_font_set_funcs (font,
 		     _hb_ot_get_font_funcs (),
 		     ot_font,
-		     (hb_destroy_func_t) _hb_ot_font_destroy);
+		     _hb_ot_font_destroy);
 }


More information about the HarfBuzz mailing list