ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ftmemory.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /***************************************************************************/
23 /* */
24 /* ftmemory.h */
25 /* */
26 /* The FreeType memory management macros (specification). */
27 /* */
28 /* Copyright 1996-2001, 2002 by */
29 /* David Turner, Robert Wilhelm, and Werner Lemberg */
30 /* */
31 /* This file is part of the FreeType project, and may only be used, */
32 /* modified, and distributed under the terms of the FreeType project */
33 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
34 /* this file you indicate that you have read the license and */
35 /* understand and accept it fully. */
36 /* */
37 /***************************************************************************/
38 
39 
40 #ifndef AGS_LIB_FREETYPE_FTMEMORY_H
41 #define AGS_LIB_FREETYPE_FTMEMORY_H
42 
43 
44 #include <ft2build.h>
45 #include FT_TYPES_H
46 
47 namespace AGS3 {
48 namespace FreeType213 {
49 
50 
51 #undef FT_SET_ERROR
52 #define FT_SET_ERROR(expression) ((error = (expression)) != 0)
53 
54 
55 FT_Error FT_Alloc(FT_Memory memory, FT_Long size, void **P);
56 FT_Error FT_Realloc(FT_Memory memory, FT_Long current, FT_Long size, void **P);
57 void FT_Free(FT_Memory memory, void **P);
58 
59 
60 #define FT_MEM_SET(dest, byte, count) ft_memset(dest, byte, count)
61 #define FT_MEM_COPY(dest, source, count) ft_memcpy(dest, source, count)
62 #define FT_MEM_MOVE(dest, source, count) ft_memmove(dest, source, count)
63 #define FT_MEM_ZERO(dest, count) FT_MEM_SET(dest, 0, count)
64 #define FT_ZERO(p) FT_MEM_ZERO(p, sizeof(*(p)))
65 
66 #define FT_MEM_ALLOC(_pointer_, _size_) FT_Alloc(memory, _size_, (void **)&(_pointer_))
67 #define FT_MEM_FREE(_pointer_) FT_Free(memory, (void **)&(_pointer_))
68 #define FT_MEM_REALLOC(_pointer_, _current_, _size_) FT_Realloc(memory, _current_, _size_, (void **)&(_pointer_))
69 
70 
71 /*************************************************************************/
72 /* */
73 /* The following functions macros expect that their pointer argument is */
74 /* _typed_ in order to automatically compute array element sizes. */
75 /* */
76 
77 #define FT_MEM_NEW(_pointer_) FT_MEM_ALLOC(_pointer_, sizeof(*(_pointer_)))
78 #define FT_MEM_NEW_ARRAY(_pointer_, _count_) FT_MEM_ALLOC(_pointer_, (_count_) * sizeof(*(_pointer_)))
79 #define FT_MEM_RENEW_ARRAY(_pointer_, _old_, _new_) FT_MEM_REALLOC(_pointer_, (_old_) * sizeof(*(_pointer_)), (_new_) * sizeof(*(_pointer_)))
80 
81 /*************************************************************************/
82 /* */
83 /* the following macros are obsolete but kept for compatibility reasons */
84 /* */
85 
86 #define FT_MEM_ALLOC_ARRAY(_pointer_, _count_, _type_) FT_MEM_ALLOC(_pointer_, (_count_) * sizeof(_type_))
87 #define FT_MEM_REALLOC_ARRAY(_pointer_, _old_, _new_, _type_) FT_MEM_REALLOC(_pointer_, (_old_) * sizeof(_type), (_new_) * sizeof(_type_))
88 
89 /*************************************************************************/
90 /* */
91 /* The following macros are variants of their FT_MEM_XXXX equivalents; */
92 /* they are used to set an _implicit_ `error' variable and return TRUE */
93 /* if an error occurred (i.e. if 'error != 0'). */
94 /* */
95 
96 #define FT_ALLOC(_pointer_, _size_) FT_SET_ERROR(FT_MEM_ALLOC(_pointer_, _size_))
97 #define FT_REALLOC(_pointer_, _current_, _size_) FT_SET_ERROR(FT_MEM_REALLOC(_pointer_, _current_, _size_))
98 #define FT_FREE(_pointer_) FT_MEM_FREE(_pointer_)
99 #define FT_NEW(_pointer_) FT_SET_ERROR(FT_MEM_NEW(_pointer_))
100 #define FT_NEW_ARRAY(_pointer_, _count_) FT_SET_ERROR(FT_MEM_NEW_ARRAY(_pointer_, _count_))
101 #define FT_RENEW_ARRAY(_pointer_, _old_, _new_) FT_SET_ERROR(FT_MEM_RENEW_ARRAY(_pointer_, _old_, _new_))
102 #define FT_ALLOC_ARRAY(_pointer_, _count_, _type_) FT_SET_ERROR(FT_MEM_ALLOC(_pointer_, (_count_) * sizeof(_type_)))
103 #define FT_REALLOC_ARRAY(_pointer_, _old_, _new_, _type_) FT_SET_ERROR(FT_MEM_REALLOC(_pointer_, (_old_) * sizeof(_type_), (_new_) * sizeof(_type_)))
104 
105 
106 } // End of namespace FreeType213
107 } // End of namespace AGS3
108 
109 #endif /* __FTMEMORY_H__ */
Definition: ags.h:40