From d8951c0cc2474176910277e8ca840fba5d8f3655 Mon Sep 17 00:00:00 2001 From: Patrick Lam Date: Wed, 8 Mar 2006 02:30:43 +0000 Subject: [PATCH] Remove stuff we don't use, make get_{char,short,long} functions of ftglue macros to be inlined. Code cleanups (excess prototype, old-style function definition). reviewed by: plam --- ChangeLog | 14 ++++++++++++ src/fcfreetype.c | 8 +++---- src/fcint.h | 3 --- src/fcname.c | 2 +- src/ftglue.c | 55 +++++++----------------------------------------- src/ftglue.h | 39 ++++++++++------------------------ 6 files changed, 38 insertions(+), 83 deletions(-) diff --git a/ChangeLog b/ChangeLog index 20d8f85..5598eab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2006-03-07 Behdad Esfahbod + reviewed by: plam + + * src/fcfreetype.c (GetScriptTags): + * src/ftglue.c, src/ftglue.h: + + Remove stuff we don't use, make get_{char,short,long} functions + of ftglue macros to be inlined. + + * src/fcint.h: + * src/fcname.c (FcObjectSerialize): + + Code cleanups (excess prototype, old-style function definition). + 2006-03-05 Patrick Lam * src/fcpat.c (FcPatternGetString): diff --git a/src/fcfreetype.c b/src/fcfreetype.c index 8e98b64..455f059 100644 --- a/src/fcfreetype.c +++ b/src/fcfreetype.c @@ -2762,7 +2762,7 @@ GetScriptTags(FT_Face face, FT_ULong tabletag, FT_ULong **stags, FT_UShort *scri if ( ftglue_stream_seek ( stream, base_offset + 4L ) || ftglue_stream_frame_enter( stream, 2L ) ) return error; - new_offset = ((FT_UShort)ftglue_stream_get_short ( stream )) + base_offset; + new_offset = GET_UShort() + base_offset; ftglue_stream_frame_exit( stream ); @@ -2776,7 +2776,7 @@ GetScriptTags(FT_Face face, FT_ULong tabletag, FT_ULong **stags, FT_UShort *scri if ( ftglue_stream_frame_enter( stream, 2L ) ) return error; - *script_count = ((FT_UShort)ftglue_stream_get_short ( stream )); + *script_count = GET_UShort (); ftglue_stream_frame_exit( stream ); @@ -2791,8 +2791,8 @@ GetScriptTags(FT_Face face, FT_ULong tabletag, FT_ULong **stags, FT_UShort *scri if ( ftglue_stream_frame_enter( stream, 6L ) ) goto Fail; - (*stags)[p] = ((FT_ULong)ftglue_stream_get_long ( stream )); - new_offset = ((FT_UShort)ftglue_stream_get_short ( stream )) + base_offset; + (*stags)[p] = GET_ULong (); + new_offset = GET_UShort () + base_offset; ftglue_stream_frame_exit( stream ); diff --git a/src/fcint.h b/src/fcint.h index 3f7f15b..84df88d 100644 --- a/src/fcint.h +++ b/src/fcint.h @@ -912,9 +912,6 @@ FcPatternEltU (FcPatternEltPtr pei) return &_fcPatternElts[FcCacheBankToIndex(pei.bank)][pei.u.stat]; } -FcPatternElt * -FcPatternEltU (FcPatternEltPtr pei); - FcValueListPtr FcValueListPtrCreateDynamic(FcValueList * p); diff --git a/src/fcname.c b/src/fcname.c index 3c902cd..c6c187a 100644 --- a/src/fcname.c +++ b/src/fcname.c @@ -358,7 +358,7 @@ FcObjectDistributeBytes (FcCache * metadata, void * block_ptr) } void -FcObjectSerialize () +FcObjectSerialize (void) { int i; for (i = 0; i < biggest_known_ntypes; i++) diff --git a/src/ftglue.c b/src/ftglue.c index 5b48b11..0ad935e 100644 --- a/src/ftglue.c +++ b/src/ftglue.c @@ -50,6 +50,14 @@ ftglue_qalloc( FT_Memory memory, #undef QALLOC /* just in case */ #define QALLOC(ptr,size) ( (ptr) = ftglue_qalloc( memory, (size), &error ), error != 0 ) +#define FREE(_ptr) \ + do { \ + if ( (_ptr) ) \ + { \ + ftglue_free( memory, _ptr ); \ + _ptr = NULL; \ + } \ + } while (0) FTGLUE_APIDEF( FT_Pointer ) @@ -212,53 +220,6 @@ ftglue_stream_frame_exit( FT_Stream stream ) } -FTGLUE_APIDEF( FT_Byte ) -ftglue_stream_get_byte( FT_Stream stream ) -{ - FT_Byte result = 0; - - if ( stream->cursor < stream->limit ) - result = *stream->cursor++; - - return result; -} - - -FTGLUE_APIDEF( FT_Short ) -ftglue_stream_get_short( FT_Stream stream ) -{ - FT_Byte* p; - FT_Short result = 0; - - p = stream->cursor; - if ( p + 2 <= stream->limit ) - { - result = (FT_Short)((p[0] << 8) | p[1]); - stream->cursor = p+2; - } - return result; -} - - -FTGLUE_APIDEF( FT_Long ) -ftglue_stream_get_long( FT_Stream stream ) -{ - FT_Byte* p; - FT_Long result = 0; - - p = stream->cursor; - if ( p + 4 <= stream->limit ) - { - result = (FT_Long)(((FT_Long)p[0] << 24) | - ((FT_Long)p[1] << 16) | - ((FT_Long)p[2] << 8) | - p[3] ); - stream->cursor = p+4; - } - return result; -} - - FTGLUE_APIDEF( FT_Error ) ftglue_face_goto_table( FT_Face face, FT_ULong the_tag, diff --git a/src/ftglue.h b/src/ftglue.h index f526bf0..93fd91e 100644 --- a/src/ftglue.h +++ b/src/ftglue.h @@ -71,9 +71,17 @@ FT_BEGIN_HEADER #define ACCESS_Frame(size) SET_ERR( ftglue_stream_frame_enter( stream, size ) ) #define FORGET_Frame() ftglue_stream_frame_exit( stream ) -#define GET_Byte() ftglue_stream_get_byte( stream ) -#define GET_Short() ftglue_stream_get_short( stream ) -#define GET_Long() ftglue_stream_get_long( stream ) +#define GET_Byte() (*stream->cursor++) +#define GET_Short() (stream->cursor += 2, (FT_Short)( \ + (*(((FT_Byte*)stream->cursor)-2) << 8) | \ + *(((FT_Byte*)stream->cursor)-1) \ + )) +#define GET_Long() (stream->cursor += 4, (FT_Long)( \ + (*(((FT_Byte*)stream->cursor)-4) << 24) | \ + (*(((FT_Byte*)stream->cursor)-3) << 16) | \ + (*(((FT_Byte*)stream->cursor)-2) << 8) | \ + *(((FT_Byte*)stream->cursor)-1) \ + )) #define GET_Char() ((FT_Char)GET_Byte()) #define GET_UShort() ((FT_UShort)GET_Short()) @@ -111,31 +119,6 @@ ftglue_face_goto_table( FT_Face face, FT_ULong tag, FT_Stream stream ); -/* memory macros used by the OpenType parser */ -#define ALLOC(_ptr,_size) \ - ( (_ptr) = ftglue_alloc( memory, _size, &error ), error != 0 ) - -#define REALLOC(_ptr,_oldsz,_newsz) \ - ( (_ptr) = ftglue_realloc( memory, (_ptr), (_oldsz), (_newsz), &error ), error != 0 ) - -#define FREE(_ptr) \ - do { \ - if ( (_ptr) ) \ - { \ - ftglue_free( memory, _ptr ); \ - _ptr = NULL; \ - } \ - } while (0) - -#define ALLOC_ARRAY(_ptr,_count,_type) \ - ALLOC(_ptr,(_count)*sizeof(_type)) - -#define REALLOC_ARRAY(_ptr,_oldcnt,_newcnt,_type) \ - REALLOC(_ptr,(_oldcnt)*sizeof(_type),(_newcnt)*sizeof(_type)) - -#define MEM_Copy(dest,source,count) memcpy( (char*)(dest), (const char*)(source), (size_t)(count) ) - - FTGLUE_API( FT_Pointer ) ftglue_alloc( FT_Memory memory, FT_ULong size, -- 2.39.5