diff --git a/ChangeLog b/ChangeLog index 5f9aec610..842cd6253 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,11 @@ 2006-05-03 David Turner - * include/freetype/internal/ftmemory.h: allow compilation with - C++ compilers + Allow compilation again with C++ compilers. + + * include/freetype/internal/ftmemory.h (FT_ASSIGNP, + FT_ASSIGNP_INNER): New macros which do the actual assignment, and + which exist in two variants (for C and C++). + Update callers accordingly. 2006-05-03 Werner Lemberg diff --git a/include/freetype/internal/ftmemory.h b/include/freetype/internal/ftmemory.h index d7f4ded5d..a4c1a7000 100644 --- a/include/freetype/internal/ftmemory.h +++ b/include/freetype/internal/ftmemory.h @@ -57,14 +57,16 @@ FT_BEGIN_HEADER /*************************************************************************/ - /* C++ absolutely hates statements like p = (void*)anything; where 'p' is - * a typed pointer. Since we don't have a typeof operator in standard C++, - * we need some really ugly casts, like: - */ + /* + * C++ refuses to handle statements like p = (void*)anything; where `p' + * is a typed pointer. Since we don't have a `typeof' operator in + * standard C++, we have to use ugly casts. + */ + #ifdef __cplusplus -# define FT_ASSIGNP(p,val) *((void**)&(p)) = (val) +#define FT_ASSIGNP( p, val ) *((void**)&(p)) = (val) #else -# define FT_ASSIGNP(p,val) (p) = (val) +#define FT_ASSIGNP( p, val ) (p) = (val) #endif @@ -74,18 +76,18 @@ FT_BEGIN_HEADER FT_BASE( const char* ) _ft_debug_file; FT_BASE( long ) _ft_debug_lineno; -# define FT_DEBUG_INNER( exp ) ( _ft_debug_file = __FILE__, \ - _ft_debug_lineno = __LINE__, \ - (exp) ) +#define FT_DEBUG_INNER( exp ) ( _ft_debug_file = __FILE__, \ + _ft_debug_lineno = __LINE__, \ + (exp) ) -# define FT_ASSIGNP_INNER( p, exp ) ( _ft_debug_file = __FILE__, \ - _ft_debug_lineno = __LINE__, \ - FT_ASSIGNP( p, exp ) ) +#define FT_ASSIGNP_INNER( p, exp ) ( _ft_debug_file = __FILE__, \ + _ft_debug_lineno = __LINE__, \ + FT_ASSIGNP( p, exp ) ) #else /* !FT_DEBUG_MEMORY */ -# define FT_DEBUG_INNER( exp ) (exp) -# define FT_ASSIGNP_INNER( p, exp ) FT_ASSIGNP( p, exp ) +#define FT_DEBUG_INNER( exp ) (exp) +#define FT_ASSIGNP_INNER( p, exp ) FT_ASSIGNP( p, exp ) #endif /* !FT_DEBUG_MEMORY */ @@ -127,7 +129,7 @@ FT_BEGIN_HEADER const void* P ); -#define FT_MEM_ALLOC( ptr, size ) \ +#define FT_MEM_ALLOC( ptr, size ) \ FT_ASSIGNP_INNER( ptr, ft_mem_alloc( memory, (size), &error ) ) #define FT_MEM_FREE( ptr ) \ @@ -144,7 +146,7 @@ FT_BEGIN_HEADER (cursz), (newsz), \ (ptr), &error ) ) -#define FT_MEM_QALLOC( ptr, size ) \ +#define FT_MEM_QALLOC( ptr, size ) \ FT_ASSIGNP_INNER( ptr, ft_mem_qalloc( memory, (size), &error ) ) #define FT_MEM_QNEW( ptr ) \ @@ -155,22 +157,22 @@ FT_BEGIN_HEADER (cursz), (newsz), \ (ptr), &error ) ) -#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \ +#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \ FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \ (cursz), (newsz), \ (ptr), &error ) ) -#define FT_MEM_ALLOC_MULT( ptr, count, item_size ) \ +#define FT_MEM_ALLOC_MULT( ptr, count, item_size ) \ FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, (item_size), \ 0, (count), \ NULL, &error ) ) -#define FT_MEM_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ +#define FT_MEM_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, (itmsz), \ (oldcnt), (newcnt), \ (ptr), &error ) ) -#define FT_MEM_QALLOC_MULT( ptr, count, item_size ) \ +#define FT_MEM_QALLOC_MULT( ptr, count, item_size ) \ FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, (item_size), \ 0, (count), \ NULL, &error ) ) @@ -222,22 +224,22 @@ FT_BEGIN_HEADER /* _typed_ in order to automatically compute array element sizes. */ /* */ -#define FT_MEM_NEW_ARRAY( ptr, count ) \ +#define FT_MEM_NEW_ARRAY( ptr, count ) \ FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, sizeof ( *(ptr) ), \ 0, (count), \ NULL, &error ) ) -#define FT_MEM_RENEW_ARRAY( ptr, cursz, newsz ) \ +#define FT_MEM_RENEW_ARRAY( ptr, cursz, newsz ) \ FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, sizeof ( *(ptr) ), \ (cursz), (newsz), \ (ptr), &error ) ) -#define FT_MEM_QNEW_ARRAY( ptr, count ) \ +#define FT_MEM_QNEW_ARRAY( ptr, count ) \ FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \ 0, (count), \ NULL, &error ) ) -#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \ +#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \ FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \ (cursz), (newsz), \ (ptr), &error ) )