macros to be inlined.
Code cleanups (excess prototype, old-style function definition).
reviewed by: plam
+2006-03-07 Behdad Esfahbod <behdad@cs.toronto.edu>
+ 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 <plam@mit.edu>
* src/fcpat.c (FcPatternGetString):
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 );
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 );
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 );
return &_fcPatternElts[FcCacheBankToIndex(pei.bank)][pei.u.stat];
}
-FcPatternElt *
-FcPatternEltU (FcPatternEltPtr pei);
-
FcValueListPtr
FcValueListPtrCreateDynamic(FcValueList * p);
}
void
-FcObjectSerialize ()
+FcObjectSerialize (void)
{
int i;
for (i = 0; i < biggest_known_ntypes; i++)
#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 )
}
-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,
#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())
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,