From 95bc9d3a0713596bc83ddfc0d487488fefc4dc88 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Wed, 16 May 2007 15:19:42 +0000 Subject: [PATCH] * src/cache/ftccache.c (ftc_node_mru_link, ftc_node_mru_unlink), src/cache/ftccache.h (FTC_CACHE_LOOKUP_CMP), src/cache/ftcglyph.h (FTC_GCACHE_LOOKUP_CMP), src/pshinter/pshmod.c (ps_hinter_init), src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_load_hhea, tt_face_get_metrics): Fix type-punning issues. --- ChangeLog | 8 ++++++++ src/cache/ftccache.c | 12 +++++++++--- src/cache/ftccache.h | 5 +++-- src/cache/ftcglyph.h | 15 +++++++++------ src/pshinter/pshmod.c | 7 ++++--- src/sfnt/ttmtx.c | 32 ++++++++++++++++++++++---------- 6 files changed, 55 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index f781a9043..a24e9fbcc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-05-16 Werner Lemberg + + * src/cache/ftccache.c (ftc_node_mru_link, ftc_node_mru_unlink), + src/cache/ftccache.h (FTC_CACHE_LOOKUP_CMP), src/cache/ftcglyph.h + (FTC_GCACHE_LOOKUP_CMP), src/pshinter/pshmod.c (ps_hinter_init), + src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_load_hhea, + tt_face_get_metrics): Fix type-punning issues. + 2007-05-15 David Turner * include/freetype/config/ftstdlib.h, diff --git a/src/cache/ftccache.c b/src/cache/ftccache.c index 797d35f6d..f3e699c38 100644 --- a/src/cache/ftccache.c +++ b/src/cache/ftccache.c @@ -4,7 +4,7 @@ /* */ /* The FreeType internal cache interface (body). */ /* */ -/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006 by */ +/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -46,7 +46,10 @@ ftc_node_mru_link( FTC_Node node, FTC_Manager manager ) { - FTC_MruNode_Prepend( (FTC_MruNode*)&manager->nodes_list, + void *nl = &manager->nodes_list; + + + FTC_MruNode_Prepend( (FTC_MruNode*)nl, (FTC_MruNode)node ); manager->num_nodes++; } @@ -57,7 +60,10 @@ ftc_node_mru_unlink( FTC_Node node, FTC_Manager manager ) { - FTC_MruNode_Remove( (FTC_MruNode*)&manager->nodes_list, + void *nl = &manager->nodes_list; + + + FTC_MruNode_Remove( (FTC_MruNode*)nl, (FTC_MruNode)node ); manager->num_nodes--; } diff --git a/src/cache/ftccache.h b/src/cache/ftccache.h index 6c9b9b9e8..8c0a7c94f 100644 --- a/src/cache/ftccache.h +++ b/src/cache/ftccache.h @@ -4,7 +4,7 @@ /* */ /* FreeType internal cache interface (specification). */ /* */ -/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006 by */ +/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -233,10 +233,11 @@ FT_BEGIN_HEADER \ { \ FTC_Manager _manager = _cache->manager; \ + void* _nl = &_manager->nodes_list; \ \ \ if ( _node != _manager->nodes_list ) \ - FTC_MruNode_Up( (FTC_MruNode*)&_manager->nodes_list, \ + FTC_MruNode_Up( (FTC_MruNode*)_nl, \ (FTC_MruNode)_node ); \ } \ goto _Ok; \ diff --git a/src/cache/ftcglyph.h b/src/cache/ftcglyph.h index 1a5d12deb..87a4199bf 100644 --- a/src/cache/ftcglyph.h +++ b/src/cache/ftcglyph.h @@ -4,7 +4,7 @@ /* */ /* FreeType abstract glyph cache (specification). */ /* */ -/* Copyright 2000-2001, 2003, 2004, 2006 by */ +/* Copyright 2000-2001, 2003, 2004, 2006, 2007 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -300,11 +300,14 @@ FT_BEGIN_HEADER #else /* !FTC_INLINE */ -#define FTC_GCACHE_LOOKUP_CMP( cache, famcmp, nodecmp, hash, \ - gindex, query, node, error ) \ - FT_BEGIN_STMNT \ - error = FTC_GCache_Lookup( FTC_GCACHE( cache ), hash, gindex, \ - FTC_GQUERY( query ), (FTC_Node*)&(node) ); \ +#define FTC_GCACHE_LOOKUP_CMP( cache, famcmp, nodecmp, hash, \ + gindex, query, node, error ) \ + FT_BEGIN_STMNT \ + void* _n = &(node); \ + \ + \ + error = FTC_GCache_Lookup( FTC_GCACHE( cache ), hash, gindex, \ + FTC_GQUERY( query ), (FTC_Node*)_n ); \ FT_END_STMNT #endif /* !FTC_INLINE */ diff --git a/src/pshinter/pshmod.c b/src/pshinter/pshmod.c index 5b18684c7..4eb3d9127 100644 --- a/src/pshinter/pshmod.c +++ b/src/pshinter/pshmod.c @@ -4,7 +4,7 @@ /* */ /* FreeType PostScript hinter module implementation (body). */ /* */ -/* Copyright 2001, 2002 by */ +/* Copyright 2001, 2002, 2007 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -51,6 +51,7 @@ ps_hinter_init( PS_Hinter_Module module ) { FT_Memory memory = module->root.memory; + void* ph = &module->ps_hints; ps_hints_init( &module->ps_hints, memory ); @@ -58,10 +59,10 @@ psh_globals_funcs_init( &module->globals_funcs ); t1_hints_funcs_init( &module->t1_funcs ); - module->t1_funcs.hints = (T1_Hints)&module->ps_hints; + module->t1_funcs.hints = (T1_Hints)ph; t2_hints_funcs_init( &module->t2_funcs ); - module->t2_funcs.hints = (T2_Hints)&module->ps_hints; + module->t2_funcs.hints = (T2_Hints)ph; return 0; } diff --git a/src/sfnt/ttmtx.c b/src/sfnt/ttmtx.c index 63837b4f2..0289b85d8 100644 --- a/src/sfnt/ttmtx.c +++ b/src/sfnt/ttmtx.c @@ -110,40 +110,48 @@ FT_ULong table_len; FT_Long num_shorts, num_longs, num_shorts_checked; - TT_LongMetrics * longs; + TT_LongMetrics* longs; TT_ShortMetrics** shorts; FT_Byte* p; if ( vertical ) { + void* lm = &face->vertical.long_metrics; + void** sm = &face->vertical.short_metrics; + + error = face->goto_table( face, TTAG_vmtx, stream, &table_len ); if ( error ) goto Fail; num_longs = face->vertical.number_Of_VMetrics; if ( (FT_ULong)num_longs > table_len / 4 ) - num_longs = (FT_Long)(table_len / 4); + num_longs = (FT_Long)( table_len / 4 ); face->vertical.number_Of_VMetrics = 0; - longs = (TT_LongMetrics *)&face->vertical.long_metrics; - shorts = (TT_ShortMetrics**)&face->vertical.short_metrics; + longs = (TT_LongMetrics*)lm; + shorts = (TT_ShortMetrics**)sm; } else { + void* lm = &face->horizontal.long_metrics; + void** sm = &face->horizontal.short_metrics; + + error = face->goto_table( face, TTAG_hmtx, stream, &table_len ); if ( error ) goto Fail; num_longs = face->horizontal.number_Of_HMetrics; if ( (FT_ULong)num_longs > table_len / 4 ) - num_longs = (FT_Long)(table_len / 4); + num_longs = (FT_Long)( table_len / 4 ); face->horizontal.number_Of_HMetrics = 0; - longs = (TT_LongMetrics *)&face->horizontal.long_metrics; - shorts = (TT_ShortMetrics**)&face->horizontal.short_metrics; + longs = (TT_LongMetrics*)lm; + shorts = (TT_ShortMetrics**)sm; } /* never trust derived values */ @@ -279,11 +287,14 @@ if ( vertical ) { + void *v = &face->vertical; + + error = face->goto_table( face, TTAG_vhea, stream, 0 ); if ( error ) goto Fail; - header = (TT_HoriHeader*)&face->vertical; + header = (TT_HoriHeader*)v; } else { @@ -415,8 +426,9 @@ FT_Short* abearing, FT_UShort* aadvance ) { - TT_HoriHeader* header = vertical ? (TT_HoriHeader*)&face->vertical - : &face->horizontal; + void* v = &face->vertical; + void* h = &face->horizontal; + TT_HoriHeader* header = vertical ? (TT_HoriHeader*)v : h; TT_LongMetrics longs_m; FT_UShort k = header->number_Of_HMetrics;