ReactOS 0.4.15-dev-5667-ged97270
psarrst.c File Reference
#include "psft.h"
#include "psglue.h"
#include "psarrst.h"
#include "pserror.h"
Include dependency graph for psarrst.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 cf2_arrstack_init (CF2_ArrStack arrstack, FT_Memory memory, FT_Error *error, size_t sizeItem)
 
 cf2_arrstack_finalize (CF2_ArrStack arrstack)
 
static FT_Bool cf2_arrstack_setNumElements (CF2_ArrStack arrstack, size_t numElements)
 
 cf2_arrstack_setCount (CF2_ArrStack arrstack, size_t numElements)
 
 cf2_arrstack_clear (CF2_ArrStack arrstack)
 
 cf2_arrstack_size (const CF2_ArrStack arrstack)
 
 cf2_arrstack_getBuffer (const CF2_ArrStack arrstack)
 
 cf2_arrstack_getPointer (const CF2_ArrStack arrstack, size_t idx)
 
 cf2_arrstack_push (CF2_ArrStack arrstack, const void *ptr)
 

Function Documentation

◆ cf2_arrstack_clear()

cf2_arrstack_clear ( CF2_ArrStack  arrstack)

Definition at line 158 of file psarrst.c.

159 {
160 FT_ASSERT( arrstack );
161
162 arrstack->count = 0;
163 }
#define FT_ASSERT(condition)
Definition: ftdebug.h:211

Referenced by cf2_hintmap_adjustHints(), and cf2_interpT2CharString().

◆ cf2_arrstack_finalize()

cf2_arrstack_finalize ( CF2_ArrStack  arrstack)

Definition at line 76 of file psarrst.c.

77 {
78 FT_Memory memory = arrstack->memory; /* for FT_FREE */
79
80
81 FT_ASSERT( arrstack );
82
83 arrstack->allocated = 0;
84 arrstack->count = 0;
85 arrstack->totalSize = 0;
86
87 /* free the data buffer */
88 FT_FREE( arrstack->ptr );
89 }
#define FT_FREE(ptr)
Definition: ftmemory.h:329
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
static char memory[1024 *256]
Definition: process.c:116

Referenced by cf2_glyphpath_finalize(), and cf2_interpT2CharString().

◆ cf2_arrstack_getBuffer()

cf2_arrstack_getBuffer ( const CF2_ArrStack  arrstack)

Definition at line 177 of file psarrst.c.

178 {
179 FT_ASSERT( arrstack );
180
181 return arrstack->ptr;
182 }

Referenced by cf2_interpT2CharString().

◆ cf2_arrstack_getPointer()

cf2_arrstack_getPointer ( const CF2_ArrStack  arrstack,
size_t  idx 
)

Definition at line 187 of file psarrst.c.

189 {
190 void* newPtr;
191
192
193 FT_ASSERT( arrstack );
194
195 if ( idx >= arrstack->count )
196 {
197 /* overflow */
198 CF2_SET_ERROR( arrstack->error, Stack_Overflow );
199 idx = 0; /* choose safe default */
200 }
201
202 newPtr = (FT_Byte*)arrstack->ptr + idx * arrstack->sizeItem;
203
204 return newPtr;
205 }
unsigned int idx
Definition: utils.c:41
unsigned char FT_Byte
Definition: fttypes.h:154
#define CF2_SET_ERROR(error, e)
Definition: pserror.h:109

Referenced by cf2_hint_init(), cf2_hintmap_adjustHints(), cf2_hintmap_build(), and cf2_interpT2CharString().

◆ cf2_arrstack_init()

cf2_arrstack_init ( CF2_ArrStack  arrstack,
FT_Memory  memory,
FT_Error error,
size_t  sizeItem 
)

Definition at line 56 of file psarrst.c.

60 {
61 FT_ASSERT( arrstack );
62
63 /* initialize the structure */
64 arrstack->memory = memory;
65 arrstack->error = error;
66 arrstack->sizeItem = sizeItem;
67 arrstack->allocated = 0;
68 arrstack->chunk = 10; /* chunks of 10 items */
69 arrstack->count = 0;
70 arrstack->totalSize = 0;
71 arrstack->ptr = NULL;
72 }
#define NULL
Definition: types.h:112
#define error(str)
Definition: mkdosfs.c:1605

Referenced by cf2_glyphpath_init(), and cf2_interpT2CharString().

◆ cf2_arrstack_push()

cf2_arrstack_push ( CF2_ArrStack  arrstack,
const void ptr 
)

Definition at line 212 of file psarrst.c.

214 {
215 FT_ASSERT( arrstack );
216
217 if ( arrstack->count == arrstack->allocated )
218 {
219 /* grow the buffer by one chunk */
221 arrstack, arrstack->allocated + arrstack->chunk ) )
222 {
223 /* on error, ignore the push */
224 return;
225 }
226 }
227
228 FT_ASSERT( ptr );
229
230 {
231 size_t offset = arrstack->count * arrstack->sizeItem;
232 void* newPtr = (FT_Byte*)arrstack->ptr + offset;
233
234
235 FT_MEM_COPY( newPtr, ptr, arrstack->sizeItem );
236 arrstack->count += 1;
237 }
238 }
#define FT_MEM_COPY(dest, source, count)
Definition: ftmemory.h:228
GLintptr offset
Definition: glext.h:5920
static PVOID ptr
Definition: dispmode.c:27
static FT_Bool cf2_arrstack_setNumElements(CF2_ArrStack arrstack, size_t numElements)
Definition: psarrst.c:95

Referenced by cf2_doStems(), and cf2_hintmap_adjustHints().

◆ cf2_arrstack_setCount()

cf2_arrstack_setCount ( CF2_ArrStack  arrstack,
size_t  numElements 
)

Definition at line 140 of file psarrst.c.

142 {
143 FT_ASSERT( arrstack );
144
145 if ( numElements > arrstack->allocated )
146 {
147 /* expand the allocation first */
148 if ( !cf2_arrstack_setNumElements( arrstack, numElements ) )
149 return;
150 }
151
152 arrstack->count = numElements;
153 }

Referenced by cf2_interpT2CharString().

◆ cf2_arrstack_setNumElements()

static FT_Bool cf2_arrstack_setNumElements ( CF2_ArrStack  arrstack,
size_t  numElements 
)
static

Definition at line 95 of file psarrst.c.

97 {
98 FT_ASSERT( arrstack );
99
100 {
101 FT_Error error = FT_Err_Ok; /* for FT_REALLOC */
102 FT_Memory memory = arrstack->memory; /* for FT_REALLOC */
103
104 size_t newSize = numElements * arrstack->sizeItem;
105
106
107 if ( numElements > FT_LONG_MAX / arrstack->sizeItem )
108 goto exit;
109
110
111 FT_ASSERT( newSize > 0 ); /* avoid realloc with zero size */
112
113 if ( !FT_REALLOC( arrstack->ptr, arrstack->totalSize, newSize ) )
114 {
115 arrstack->allocated = numElements;
116 arrstack->totalSize = newSize;
117
118 if ( arrstack->count > numElements )
119 {
120 /* we truncated the list! */
121 CF2_SET_ERROR( arrstack->error, Stack_Overflow );
122 arrstack->count = numElements;
123 return FALSE;
124 }
125
126 return TRUE; /* success */
127 }
128 }
129
130 exit:
131 /* if there's not already an error, store this one */
132 CF2_SET_ERROR( arrstack->error, Out_Of_Memory );
133
134 return FALSE;
135 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
return FT_Err_Ok
Definition: ftbbox.c:511
#define FT_REALLOC(ptr, cursz, newsz)
Definition: ftmemory.h:306
#define FT_LONG_MAX
Definition: ftstdlib.h:67
int FT_Error
Definition: fttypes.h:300
#define exit(n)
Definition: config.h:202

Referenced by cf2_arrstack_push(), and cf2_arrstack_setCount().

◆ cf2_arrstack_size()

cf2_arrstack_size ( const CF2_ArrStack  arrstack)

Definition at line 168 of file psarrst.c.

169 {
170 FT_ASSERT( arrstack );
171
172 return arrstack->count;
173 }

Referenced by cf2_hintmap_adjustHints(), cf2_hintmap_build(), and cf2_interpT2CharString().