Hash :
e7880499
Author :
Date :
2002-04-25T21:42:59
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
#include <ft2build.h>
#include FT_EXCEPT_H
FT_BASE_DEF( void )
ft_cleanup_stack_init( FT_CleanupStack stack,
FT_Memory memory )
{
stack->chunk = &stack->chunk_0;
stack->top = stack->chunk->items;
stack->limit = stack->top + FT_CLEANUP_CHUNK_SIZE;
stack->chunk_0.link = NULL;
stack->memory = memory;
}
FT_BASE_DEF( void )
ft_cleanup_stack_done( FT_CleanupStack stack )
{
FT_Memory memory = stack->memory;
FT_CleanupChunk chunk, next;
for (;;)
{
chunk = stack->chunk;
if ( chunk == &stack->chunk_0 )
break;
stack->chunk = chunk->link;
FT_FREE( chunk );
}
stack->memory = NULL;
}
FT_BASE_DEF( void )
ft_cleanup_stack_push( FT_CleanupStack stack,
FT_Pointer item,
FT_CleanupFunc item_func,
FT_Pointer item_data )
{
FT_CleanupItem top;
FT_ASSERT( stack && stack->chunk && stack->top );
FT_ASSERT( item && item_func );
top = stack->top;
top->item = item;
top->item_func = item_func;
top->item_data = item_data;
top ++;
if ( top == stack->limit )
{
FT_CleanupChunk chunk;
FT_Error error;
if ( FT_ALLOC( chunk, stack->memory ) )
ft_cleanup_stack_throw( stack, error );
chunk->link = stack->chunk;
stack->chunk = chunk;
stack->limit = chunk->items + FT_CLEANUP_CHUNK_SIZE;
top = chunk->items;
}
stack->top = top;
}
FT_BASE_DEF( void )
ft_cleanup_stack_pop( FT_CleanupStack stack,
FT_Int destroy )
{
FT_CleanupItem top;
FT_ASSERT( stack && stack->chunk && stack->top );
top = stack->top;
if ( top == stack->chunk->items )
{
FT_CleanupChunk chunk;
chunk = stack->chunk;
if ( chunk == &stack->chunk_0 )
{
FT_ERROR(( "cleanup.pop: empty cleanup stack !!\n" ));
ft_cleanup_throw( stack, FT_Err_EmptyCleanupStack );
}
chunk = chunk->link;
FT_QFree( stack->chunk, stack->memory );
stack->chunk = chunk;
stack->limit = chunk->items + FT_CLEANUP_CHUNK_SIZE;
top = stack->limit;
}
top --;
if ( destroy )
top->item_func( top->item, top->item_data );
top->item = NULL;
top->item_func = NULL;
top->item_data = NULL;
stack->top = top;
}
FT_BASE_DEF( FT_CleanupItem )
ft_cleanup_stack_peek( FT_CleanupStack stack )
{
FT_CleanupItem top;
FT_CleanupChunk chunk;
FT_ASSERT( stack && stack->chunk && stack->top );
top = stack->top;
chunk = stack->chunk;
if ( top > chunk->items )
top--;
else
{
chunk = chunk->link;
top = NULL;
if ( chunk != NULL )
top = chunk->items + FT_CLEANUP_CHUNK_SIZE - 1;
}
return top;
}
FT_BASE_DEF( void )
ft_cleanup_stack_throw( FT_CleanupStack stack, FT_Error error )
{
}
FT_BASE_DEF( void )
ft_xhandler_enter( FT_XHandler xhandler,
FT_Memory memory )
{
}
FT_BASE_DEF( void )
ft_xhandler_exit( FT_XHandler xhandler )
{
}