ref: 679a252c24e3ccbe2dadfacd363139f7e1dd01cb
parent: 58eed04d5aa034c9af3e2919a0b49fc92a4df75b
author: David Turner <[email protected]>
date: Wed May 3 05:40:33 EDT 2006
* include/freetype/internal/ftmemory.h: allow compilation with C++ compilers
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-05-03 David Turner <[email protected]>
+
+ * include/freetype/internal/ftmemory.h: allow compilation with
+ C++ compilers
+
2006-05-03 Werner Lemberg <[email protected]>
* include/freetype/config/ftoption.h (FT_STRICT_ALIASING): Removed.
--- a/include/freetype/internal/ftmemory.h
+++ b/include/freetype/internal/ftmemory.h
@@ -57,18 +57,35 @@
/*************************************************************************/
+ /* 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:
+ */
+#ifdef __cplusplus
+# define FT_ASSIGNP(p,val) *((void**)&(p)) = (val)
+#else
+# define FT_ASSIGNP(p,val) (p) = (val)
+#endif
+
+
+
#ifdef FT_DEBUG_MEMORY
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 ) )
+
#else /* !FT_DEBUG_MEMORY */
-#define FT_DEBUG_INNER( exp ) (exp)
+# define FT_DEBUG_INNER( exp ) (exp)
+# define FT_ASSIGNP_INNER( p, exp ) FT_ASSIGNP( p, exp )
#endif /* !FT_DEBUG_MEMORY */
@@ -111,7 +128,7 @@
#define FT_MEM_ALLOC( ptr, size ) \
- FT_DEBUG_INNER( (ptr) = ft_mem_alloc( memory, (size), &error ) )
+ FT_ASSIGNP_INNER( ptr, ft_mem_alloc( memory, (size), &error ) )
#define FT_MEM_FREE( ptr ) \
FT_BEGIN_STMNT \
@@ -122,48 +139,48 @@
#define FT_MEM_NEW( ptr ) \
FT_MEM_ALLOC( ptr, sizeof ( *(ptr) ) )
-#define FT_MEM_REALLOC( ptr, cursz, newsz ) \
- FT_DEBUG_INNER( (ptr) = ft_mem_realloc( memory, 1, \
- (cursz), (newsz), \
- (ptr), &error ) )
+#define FT_MEM_REALLOC( ptr, cursz, newsz ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, 1, \
+ (cursz), (newsz), \
+ (ptr), &error ) )
#define FT_MEM_QALLOC( ptr, size ) \
- FT_DEBUG_INNER( (ptr) = ft_mem_qalloc( memory, (size), &error ) )
+ FT_ASSIGNP_INNER( ptr, ft_mem_qalloc( memory, (size), &error ) )
#define FT_MEM_QNEW( ptr ) \
FT_MEM_QALLOC( ptr, sizeof ( *(ptr) ) )
#define FT_MEM_QREALLOC( ptr, cursz, newsz ) \
- FT_DEBUG_INNER( (ptr) = ft_mem_qrealloc( memory, 1, \
- (cursz), (newsz), \
- (ptr), &error ) )
+ FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, 1, \
+ (cursz), (newsz), \
+ (ptr), &error ) )
#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \
- FT_DEBUG_INNER( (ptr) = ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \
- (cursz), (newsz), \
- (ptr), &error ) )
+ FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \
+ (cursz), (newsz), \
+ (ptr), &error ) )
#define FT_MEM_ALLOC_MULT( ptr, count, item_size ) \
- FT_DEBUG_INNER( (ptr) = ft_mem_realloc( memory, (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 ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, (itmsz), \
+ (oldcnt), (newcnt), \
+ (ptr), &error ) )
+
+#define FT_MEM_QALLOC_MULT( ptr, count, item_size ) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, (item_size), \
0, (count), \
NULL, &error ) )
-#define FT_MEM_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \
- FT_DEBUG_INNER( (ptr) = ft_mem_realloc( memory, (itmsz), \
+#define FT_MEM_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz) \
+ FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, (itmsz), \
(oldcnt), (newcnt), \
(ptr), &error ) )
-#define FT_MEM_QALLOC_MULT( ptr, count, item_size ) \
- FT_DEBUG_INNER( (ptr) = ft_mem_qrealloc( memory, (item_size), \
- 0, (count), \
- NULL, &error ) )
-#define FT_MEM_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz) \
- FT_DEBUG_INNER( (ptr) = ft_mem_qrealloc( memory, (itmsz), \
- (oldcnt), (newcnt), \
- (ptr), &error ) )
-
-
#define FT_MEM_SET_ERROR( cond ) ( (cond), error != 0 )
@@ -206,24 +223,24 @@
/* */
#define FT_MEM_NEW_ARRAY( ptr, count ) \
- FT_DEBUG_INNER( (ptr) = ft_mem_realloc( memory, sizeof ( *(ptr) ), \
- 0, (count), \
- NULL, &error ) )
+ FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, sizeof ( *(ptr) ), \
+ 0, (count), \
+ NULL, &error ) )
#define FT_MEM_RENEW_ARRAY( ptr, cursz, newsz ) \
- FT_DEBUG_INNER( (ptr) = ft_mem_realloc( memory, sizeof ( *(ptr) ), \
- (cursz), (newsz), \
- (ptr), &error ) )
+ FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, sizeof ( *(ptr) ), \
+ (cursz), (newsz), \
+ (ptr), &error ) )
#define FT_MEM_QNEW_ARRAY( ptr, count ) \
- FT_DEBUG_INNER( (ptr) = ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \
- 0, (count), \
- NULL, &error ) )
+ FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \
+ 0, (count), \
+ NULL, &error ) )
#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \
- FT_DEBUG_INNER( (ptr) = ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \
- (cursz), (newsz), \
- (ptr), &error ) )
+ FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \
+ (cursz), (newsz), \
+ (ptr), &error ) )
#define FT_ALLOC( ptr, size ) \