Remove cast of functions to (hb_destroy_func_t)

Fixes https://github.com/behdad/harfbuzz/issues/474
pull/562/head
Behdad Esfahbod 7 years ago
parent 717fcb51dd
commit e1b6d92302
  1. 8
      src/hb-blob.cc
  2. 10
      src/hb-coretext.cc
  3. 6
      src/hb-face.cc
  4. 20
      src/hb-ft.cc
  5. 9
      src/hb-glib.cc
  6. 6
      src/hb-ot-font.cc

@ -128,6 +128,12 @@ hb_blob_create (const char *data,
return blob; return blob;
} }
static void
_hb_blob_destroy (void *data)
{
hb_blob_destroy ((hb_blob_t *) data);
}
/** /**
* hb_blob_create_sub_blob: * hb_blob_create_sub_blob:
* @parent: Parent blob. * @parent: Parent blob.
@ -164,7 +170,7 @@ hb_blob_create_sub_blob (hb_blob_t *parent,
MIN (length, parent->length - offset), MIN (length, parent->length - offset),
HB_MEMORY_MODE_READONLY, HB_MEMORY_MODE_READONLY,
hb_blob_reference (parent), hb_blob_reference (parent),
(hb_destroy_func_t) hb_blob_destroy); _hb_blob_destroy);
return blob; return blob;
} }

@ -64,10 +64,16 @@ reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data)
release_table_data); release_table_data);
} }
static void
_hb_cg_font_release (void *data)
{
CGFontRelease ((CGFontRef) data);
}
hb_face_t * hb_face_t *
hb_coretext_face_create (CGFontRef cg_font) 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) create_cg_font (hb_face_t *face)
{ {
CGFontRef cg_font = NULL; 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); cg_font = CGFontRetain ((CGFontRef) face->user_data);
} }

@ -118,8 +118,10 @@ _hb_face_for_data_closure_create (hb_blob_t *blob, unsigned int index)
} }
static void 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); hb_blob_destroy (closure->blob);
free (closure); 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, face = hb_face_create_for_tables (_hb_face_for_data_reference_table,
closure, closure,
(hb_destroy_func_t) _hb_face_for_data_closure_destroy); _hb_face_for_data_closure_destroy);
face->index = index; face->index = index;

@ -95,14 +95,16 @@ _hb_ft_font_create (FT_Face ft_face, bool symbol, bool unref)
} }
static void 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 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) if (ft_font->unref)
_hb_ft_face_destroy (ft_font->ft_face); _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) if (font->immutable)
return; return;
if (font->destroy != (hb_destroy_func_t) _hb_ft_font_destroy) if (font->destroy != _hb_ft_font_destroy)
return; return;
hb_ft_font_t *ft_font = (hb_ft_font_t *) font->user_data; 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 int
hb_ft_font_get_load_flags (hb_font_t *font) 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; return 0;
const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font->user_data; 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 FT_Face
hb_ft_font_get_face (hb_font_t *font) 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; return NULL;
const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font->user_data; 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, hb_font_set_funcs (font,
funcs, funcs,
_hb_ft_font_create (ft_face, symbol, unref), _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) hb_ft_face_create_referenced (FT_Face ft_face)
{ {
FT_Reference_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 static void
@ -655,7 +657,7 @@ hb_font_t *
hb_ft_font_create_referenced (FT_Face ft_face) hb_ft_font_create_referenced (FT_Face ft_face)
{ {
FT_Reference_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);
} }

@ -383,6 +383,13 @@ hb_glib_get_unicode_funcs (void)
} }
#if GLIB_CHECK_VERSION(2,31,10) #if GLIB_CHECK_VERSION(2,31,10)
static void
_hb_g_bytes_unref (void *data)
{
g_bytes_unref ((GBytes *) data);
}
/** /**
* hb_glib_blob_create: * hb_glib_blob_create:
* *
@ -397,6 +404,6 @@ hb_glib_blob_create (GBytes *gbytes)
size, size,
HB_MEMORY_MODE_READONLY, HB_MEMORY_MODE_READONLY,
g_bytes_ref (gbytes), g_bytes_ref (gbytes),
(hb_destroy_func_t) g_bytes_unref); _hb_g_bytes_unref);
} }
#endif #endif

@ -458,8 +458,10 @@ _hb_ot_font_create (hb_face_t *face)
} }
static void 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->cmap.fini ();
ot_font->h_metrics.fini (); ot_font->h_metrics.fini ();
ot_font->v_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_font_set_funcs (font,
_hb_ot_get_font_funcs (), _hb_ot_get_font_funcs (),
ot_font, ot_font,
(hb_destroy_func_t) _hb_ot_font_destroy); _hb_ot_font_destroy);
} }

Loading…
Cancel
Save