* include/freetype/internal/{ftmemory.h,ftserv.h}: removing

compiler warnings with GCC 3.3 and above...
This commit is contained in:
David Turner 2005-03-03 13:58:13 +00:00
parent 0e37feda90
commit d4ac31a574
2 changed files with 125 additions and 30 deletions

View File

@ -43,6 +43,7 @@ FT_BEGIN_HEADER
( ( error = (expression) ) != 0 )
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@ -367,49 +368,92 @@ FT_BEGIN_HEADER
/* if an error occured (i.e. if 'error != 0'). */
/* */
/* GCC 3.3 and beyond will generate tons of _stupid_ warnings if we
* don't take special measures.
*/
#if defined(__GNUC__) && ( __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) )
#define FT_ALLOC( _pointer_, _size_ ) \
({ \
void* _tmp_ = NULL; \
error = FT_MEM_ALLOC( _tmp_, _size_ ); \
_pointer_ = _tmp_; \
error != 0; \
})
#define FT_REALLOC( _pointer_, _cursize_, _newsize_ ) \
({ \
void* _tmp_ = _pointer_; \
error = FT_MEM_REALLOC( _tmp_, _cursize_, _newsize_ ); \
_pointer_ = _tmp_; \
error != 0; \
})
#define FT_QALLOC( _pointer_, _size_ ) \
({ \
void* _tmp_; \
error = FT_MEM_QALLOC( _tmp_, _size_ ); \
_pointer_ = _tmp_; \
error != 0; \
})
#define FT_QREALLOC( _pointer_, _cursize_, _newsize_ ) \
({ \
void* _tmp_ = _pointer_; \
error = FT_MEM_QREALLOC( _tmp_, _cursize_, _newsize_ ); \
_pointer_ = _tmp_; \
error != 0; \
})
#else /* !GCC || GCC < 3.3 */
#define FT_ALLOC( _pointer_, _size_ ) \
FT_SET_ERROR( FT_MEM_ALLOC( _pointer_, _size_ ) )
#define FT_REALLOC( _pointer_, _current_, _size_ ) \
FT_SET_ERROR( FT_MEM_REALLOC( _pointer_, _current_, _size_ ) )
#define FT_FREE( _pointer_ ) \
FT_MEM_FREE( _pointer_ )
#define FT_QALLOC( _pointer_, _size_ ) \
FT_SET_ERROR( FT_MEM_QALLOC( _pointer_, _size_ ) )
#define FT_QREALLOC( _pointer_, _current_, _size_ ) \
FT_SET_ERROR( FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) )
#endif /* !GCC || GCC < 3.3 */
#define FT_FREE( _pointer_ ) \
FT_MEM_FREE( _pointer_ )
#define FT_NEW( _pointer_ ) \
FT_SET_ERROR( FT_MEM_NEW( _pointer_ ) )
FT_ALLOC( _pointer_, sizeof(*(_pointer_)) )
#define FT_NEW_ARRAY( _pointer_, _count_ ) \
FT_SET_ERROR( FT_MEM_NEW_ARRAY( _pointer_, _count_ ) )
FT_ALLOC( _pointer_, sizeof(*(_pointer_))*(_count_) )
#define FT_RENEW_ARRAY( _pointer_, _old_, _new_ ) \
FT_SET_ERROR( FT_MEM_RENEW_ARRAY( _pointer_, _old_, _new_ ) )
#define FT_RENEW_ARRAY( _pointer_, _old_, _new_ ) \
FT_REALLOC( _pointer_, sizeof(*(_pointer_))*(_old_), \
sizeof(*(_pointer_))*(_new_) )
#define FT_QNEW( _pointer_ ) \
FT_SET_ERROR( FT_MEM_QNEW( _pointer_ ) )
FT_QALLOC( _pointer_, sizeof(*(_pointer_)) )
#define FT_QNEW_ARRAY( _pointer_, _count_ ) \
FT_SET_ERROR( FT_MEM_QNEW_ARRAY( _pointer_, _count_ ) )
FT_QALLOC( _pointer_, sizeof(*(_pointer_))*(_count_) )
#define FT_QRENEW_ARRAY( _pointer_, _old_, _new_ ) \
FT_SET_ERROR( FT_MEM_QRENEW_ARRAY( _pointer_, _old_, _new_ ) )
#define FT_QRENEW_ARRAY( _pointer_, _old_, _new_ ) \
FT_QREALLOC( _pointer_, sizeof(*(_pointer_))*(_old_), \
sizeof(*(_pointer_))*(_new_) )
#define FT_ALLOC_ARRAY( _pointer_, _count_, _type_ ) \
FT_SET_ERROR( FT_MEM_ALLOC( _pointer_, \
(_count_) * sizeof ( _type_ ) ) )
#define FT_ALLOC_ARRAY( _pointer_, _count_, _type_ ) \
FT_ALLOC( _pointer_, (_count_)*sizeof( _type_ ) )
#define FT_REALLOC_ARRAY( _pointer_, _old_, _new_, _type_ ) \
FT_SET_ERROR( FT_MEM_REALLOC( _pointer_, \
(_old_) * sizeof ( _type_ ), \
(_new_) * sizeof ( _type_ ) ) )
#define FT_REALLOC_ARRAY( _pointer_, _old_, _new_, _type_ ) \
FT_REALLOC( _pointer, (_old_) * sizeof ( _type_ ), \
(_new_) * sizeof ( _type_ ) )
/* */

View File

@ -57,18 +57,32 @@ FT_BEGIN_HEADER
* A variable that receives the service pointer. Will be NULL
* if not found.
*/
#ifdef __cplusplus
#define FT_FACE_FIND_SERVICE( face, ptr, id ) \
FT_BEGIN_STMNT \
FT_Module module = FT_MODULE( FT_FACE(face)->driver ); \
/* the strange cast is to allow C++ compilation */ \
FT_Pointer* Pptr = (FT_Pointer*) &(ptr); \
FT_Pointer _tmp_ = NULL; \
FT_Pointer* _pptr_ = (FT_Pointer*)&(ptr); \
\
\
*Pptr = NULL; \
if ( module->clazz->get_interface ) \
*Pptr = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); \
_tmp_ = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); \
*_pptr_ = _tmp_; \
FT_END_STMNT
#else /* !C++ */
#define FT_FACE_FIND_SERVICE( face, ptr, id ) \
FT_BEGIN_STMNT \
FT_Module module = FT_MODULE( FT_FACE(face)->driver ); \
FT_Pointer _tmp_ = NULL; \
\
if ( module->clazz->get_interface ) \
_tmp_ = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); \
ptr = _tmp_; \
FT_END_STMNT
#endif /* !C++ */
/*
* @macro:
@ -92,16 +106,30 @@ FT_BEGIN_HEADER
* A variable that receives the service pointer. Will be NULL
* if not found.
*/
#ifdef __cplusplus
#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id ) \
FT_BEGIN_STMNT \
FT_Module module = FT_MODULE( FT_FACE(face)->driver ); \
/* the strange cast is to allow C++ compilation */ \
FT_Pointer* Pptr = (FT_Pointer*) &(ptr); \
FT_Pointer _tmp_; \
FT_Pointer _pptr_ = (FT_Pointer*)&(ptr); \
\
\
*Pptr = ft_module_get_service( module, FT_SERVICE_ID_ ## id ); \
_tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id ); \
*_pptr_ = _tmp_; \
FT_END_STMNT
#else /* !C++ */
#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id ) \
FT_BEGIN_STMNT \
FT_Module module = FT_MODULE( FT_FACE(face)->driver ); \
FT_Pointer _tmp_; \
\
_tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id ); \
ptr = _tmp_; \
FT_END_STMNT
#endif /* !C++ */
/*************************************************************************/
/*************************************************************************/
@ -199,10 +227,32 @@ FT_BEGIN_HEADER
* ptr ::
* A variable receiving the service data. NULL if not available.
*/
#ifdef __cplusplus
#define FT_FACE_LOOKUP_SERVICE( face, ptr, id ) \
FT_BEGIN_STMNT \
FT_Pointer svc; \
FT_Pointer* Pptr = (FT_Pointer*)&(ptr); \
\
\
svc = FT_FACE(face)->internal->services. service_ ## id; \
if ( svc == FT_SERVICE_UNAVAILABLE ) \
svc = NULL; \
else if ( svc == NULL ) \
{ \
FT_FACE_FIND_SERVICE( face, svc, id ); \
\
FT_FACE(face)->internal->services. service_ ## id = \
(FT_Pointer)( svc != NULL ? svc \
: FT_SERVICE_UNAVAILABLE ); \
} \
*Pptr = svc; \
FT_END_STMNT
#else /* !C++ */
#define FT_FACE_LOOKUP_SERVICE( face, ptr, id ) \
FT_BEGIN_STMNT \
/* the strange cast is to allow C++ compilation */ \
FT_Pointer* pptr = (FT_Pointer*)&(ptr); \
FT_Pointer svc; \
\
\
@ -217,9 +267,10 @@ FT_BEGIN_HEADER
(FT_Pointer)( svc != NULL ? svc \
: FT_SERVICE_UNAVAILABLE ); \
} \
*pptr = svc; \
ptr = svc; \
FT_END_STMNT
#endif /* !C++ */
/*
* A macro used to define new service structure types.