contrib/OWB: add correct SDL dependency, fix compilers used
[AROS-Contrib.git] / freetype1 / lib / ttmemory.h
blob8cdae2327d26de1975e5f919b16130dd2b24d420
1 /*******************************************************************
3 * ttmemory.h 1.2
5 * Memory management component (specification).
7 * Copyright 1996-1999 by
8 * David Turner, Robert Wilhelm, and Werner Lemberg.
10 * This file is part of the FreeType project, and may only be used
11 * modified and distributed under the terms of the FreeType project
12 * license, LICENSE.TXT. By continuing to use, modify, or distribute
13 * this file you indicate that you have read the license and
14 * understand and accept it fully.
16 * Changes between 1.2 and 1.1:
18 * - the font pool is gone! All allocations are now performed
19 * with malloc() and free().
21 * - introduced the FREE() macro and the Free() function for
22 * future use in destructors.
24 * - Init_FontPool() is now a macro to allow the compilation of
25 * 'legacy' applications (all four test programs have been updated).
27 ******************************************************************/
29 #ifndef TTMEMORY_H
30 #define TTMEMORY_H
32 #include "ttconfig.h"
33 #include "tttypes.h"
34 #include <string.h>
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
41 #define MEM_Set( dest, byte, count ) memset( dest, byte, count )
43 #ifdef HAVE_MEMCPY
44 #define MEM_Copy( dest, source, count ) memcpy( dest, source, count )
45 #else
46 #define MEM_Copy( dest, source, count ) bcopy( source, dest, count )
47 #endif
49 #ifdef HAVE_MEMMOVE
50 #define MEM_Move( dest, source, count ) memmove( dest, source, count )
51 #else
52 #define MEM_Move( dest, source, count ) bcopy( source, dest, count )
53 #endif
56 #define MEM_Alloc( _pointer_, _size_ ) \
57 TT_Alloc( _size_, (void**)&(_pointer_) )
59 #define MEM_Realloc( _pointer_, _size_ ) \
60 TT_Realloc( _size_, (void**)&(_pointer_) )
62 #define ALLOC( _pointer_, _size_ ) \
63 ( ( error = MEM_Alloc( _pointer_, _size_ ) ) != TT_Err_Ok )
65 #define ALLOC_ARRAY( _pointer_, _count_, _type_ ) \
66 ( ( error = MEM_Alloc( _pointer_, \
67 (_count_) * sizeof ( _type_ ) ) ) != TT_Err_Ok )
69 #define REALLOC( _pointer_, _size_ ) \
70 ( ( error = MEM_Realloc( _pointer_, _size_ ) ) != TT_Err_Ok )
72 #define REALLOC_ARRAY( _pointer_, _count_, _type_ ) \
73 ( (error = MEM_Realloc( _pointer_, \
74 (_count_) * sizeof ( _type_ ) ) ) != TT_Err_Ok )
76 #define FREE( _pointer_ ) \
77 TT_Free( (void**)&(_pointer_) )
80 /* Allocate a block of memory of 'Size' bytes from the heap, and */
81 /* sets the pointer '*P' to its address. If 'Size' is 0, or in */
82 /* case of error, the pointer is always set to NULL. */
84 EXPORT_DEF
85 TT_Error TT_Alloc( ULong Size, void** P );
87 #ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
89 /* Reallocates a block of memory pointed to by '*P' to 'Size' */
90 /* bytes from the heap, possibly changing '*P'. If 'Size' is 0, */
91 /* TT_Free() is called, if '*P' is NULL, TT_Alloc() is called. */
92 /* '*P' is freed (if it's non-NULL) in case of error. */
94 EXPORT_DEF
95 TT_Error TT_Realloc( ULong Size, void** P );
97 #endif /* TT_CONFIG_OPTION_EXTEND_ENGINE */
99 /* Releases a block that was previously allocated through Alloc. */
100 /* Note that the function returns successfully when P or *P are */
101 /* already NULL. The pointer '*P' is set to NULL on exit in */
102 /* case of success. */
104 EXPORT_DEF
105 TT_Error TT_Free( void** P );
108 /* For "legacy" applications, that should be re-coded. */
109 /* Note that this won't release the previously allocated font pool. */
111 #define Init_FontPool( x, y ) while( 0 ) { }
114 LOCAL_DEF TT_Error TTMemory_Init( void );
115 LOCAL_DEF TT_Error TTMemory_Done( void );
118 #ifdef __cplusplus
120 #endif
122 #endif /* TTMEMORY_H */
125 /* END */