FT_QRealloc( FT_Memory memory, FT_Long current, FT_Long size, void** P ) { void* Q; FT_ASSERT( P != 0 ); /* if the original pointer is NULL, call FT_QAlloc() */ if ( !*P ) return FT_QAlloc( memory, size, P ); /* if the new block if zero-sized, clear the current one */ if ( size <= 0 ) { FT_Free( memory, P ); return FT_Err_Ok; } Q = memory->realloc( memory, current, size, *P ); if ( !Q ) goto Fail; *P = Q; return FT_Err_Ok; Fail: FT_ERROR(( "FT_QRealloc:" )); FT_ERROR(( " Failed (current %ld, requested %ld)\n", current, size )); return FT_Err_Out_Of_Memory; }
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; chunk = FT_QAlloc( sizeof(*chunk), stack->memory ); chunk->link = stack->chunk; stack->chunk = chunk; stack->limit = chunk->items + FT_CLEANUP_CHUNK_SIZE; top = chunk->items; } stack->top = top; }
FT_QAlloc_Debug( FT_Memory memory, FT_Long size, void* *P, const char* file_name, FT_Long line_no ) { FT_MemTable table = (FT_MemTable)memory->user; if ( table ) { table->file_name = file_name; table->line_no = line_no; } return FT_QAlloc( memory, size, P ); }