本文整理汇总了C++中FT_Memory类的典型用法代码示例。如果您正苦于以下问题:C++ FT_Memory类的具体用法?C++ FT_Memory怎么用?C++ FT_Memory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FT_Memory类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FT_Done_FreeType_2
FT_Done_FreeType_2(FT_Library library)
{
if(library)
{
FT_Memory memory = library->memory;
FT_Done_Library(library);
memory->free(memory, memory);
}
return FT_Err_Ok;
}
示例2: ft_mem_qrealloc
ft_mem_qrealloc( FT_Memory memory,
FT_Long item_size,
FT_Long cur_count,
FT_Long new_count,
void* block,
FT_Error *p_error )
{
FT_Error error = FT_Err_Ok;
/* Note that we now accept `item_size == 0' as a valid parameter, in
* order to cover very weird cases where an ALLOC_MULT macro would be
* called.
*/
if ( cur_count < 0 || new_count < 0 || item_size < 0 )
{
/* may help catch/prevent nasty security issues */
error = FT_THROW( Invalid_Argument );
}
else if ( new_count == 0 || item_size == 0 )
{
ft_mem_free( memory, block );
block = NULL;
}
else if ( new_count > FT_INT_MAX / item_size )
{
error = FT_THROW( Array_Too_Large );
}
else if ( cur_count == 0 )
{
FT_ASSERT( !block );
block = memory->alloc( memory, new_count * item_size );
if ( block == NULL )
error = FT_THROW( Out_Of_Memory );
}
else
{
FT_Pointer block2;
FT_Long cur_size = cur_count * item_size;
FT_Long new_size = new_count * item_size;
block2 = memory->realloc( memory, cur_size, new_size, block );
if ( !block2 )
error = FT_THROW( Out_Of_Memory );
else
block = block2;
}
*p_error = error;
return block;
}
示例3: FT_Done_Memory
FT_Done_Memory( FT_Memory memory )
{
#ifdef FT_DEBUG_MEMORY
ft_mem_debug_done( memory );
#endif
memory->free( memory, memory );
}
示例4: FT_Alloc
FT_Alloc( FT_Memory memory,
FT_Long size,
void* *P )
{
FT_ASSERT( P != 0 );
if ( size > 0 )
{
*P = memory->alloc( memory, size );
if ( !*P )
{
FT_ERROR(( "FT_Alloc:" ));
FT_ERROR(( " Out of memory? (%ld requested)\n",
size ));
return FT_Err_Out_Of_Memory;
}
FT_MEM_ZERO( *P, size );
}
else
*P = NULL;
FT_TRACE7(( "FT_Alloc:" ));
FT_TRACE7(( " size = %ld, block = 0x%08p, ref = 0x%08p\n",
size, *P, P ));
return FT_Err_Ok;
}
示例5: FT_QRealloc
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;
}
示例6: FT_Free
FT_Free( FT_Memory memory,
void** P )
{
FT_TRACE7(( "FT_Free:" ));
FT_TRACE7(( " Freeing block 0x%08p, ref 0x%08p\n",
P, P ? *P : (void*)0 ));
if ( P && *P )
{
memory->free( memory, *P );
*P = 0;
}
}
示例7: ft_mem_table_new
static FT_MemTable
ft_mem_table_new( FT_Memory memory )
{
FT_MemTable table;
table = (FT_MemTable)memory->alloc( memory, sizeof ( *table ) );
if ( !table )
goto Exit;
FT_ZERO( table );
table->size = FT_MEM_SIZE_MIN;
table->nodes = 0;
table->memory = memory;
table->memory_user = memory->user;
table->alloc = memory->alloc;
table->realloc = memory->realloc;
table->free = memory->free;
table->buckets = (FT_MemNode *)
memory->alloc(
memory,
table->size * (FT_Long)sizeof ( FT_MemNode ) );
if ( table->buckets )
FT_ARRAY_ZERO( table->buckets, table->size );
else
{
memory->free( memory, table );
table = NULL;
}
Exit:
return table;
}
示例8: ft_mem_qrealloc
ft_mem_qrealloc( FT_Memory memory,
FT_Long item_size,
FT_Long cur_count,
FT_Long new_count,
void* block,
FT_Error *p_error )
{
FT_Error error = FT_Err_Ok;
if ( cur_count < 0 || new_count < 0 || item_size <= 0 )
{
/* may help catch/prevent nasty security issues */
error = FT_Err_Invalid_Argument;
}
else if ( new_count == 0 )
{
ft_mem_free( memory, block );
block = NULL;
}
else if ( new_count > FT_INT_MAX/item_size )
{
error = FT_Err_Array_Too_Large;
}
else if ( cur_count == 0 )
{
FT_ASSERT( block == NULL );
block = ft_mem_alloc( memory, new_count*item_size, &error );
}
else
{
FT_Pointer block2;
FT_Long cur_size = cur_count*item_size;
FT_Long new_size = new_count*item_size;
block2 = memory->realloc( memory, cur_size, new_size, block );
if ( block2 == NULL )
error = FT_Err_Out_Of_Memory;
else
block = block2;
}
*p_error = error;
return block;
}
示例9: ft_mem_qalloc
ft_mem_qalloc( FT_Memory memory,
FT_Long size,
FT_Error *p_error )
{
FT_Error error = FT_Err_Ok;
FT_Pointer block = NULL;
if ( size > 0 )
{
block = memory->alloc( memory, size );
if ( block == NULL )
error = FT_Err_Out_Of_Memory;
}
else if ( size < 0 )
{
/* may help catch/prevent security issues */
error = FT_Err_Invalid_Argument;
}
*p_error = error;
return block;
}
示例10: ft_mem_free
ft_mem_free( FT_Memory memory,
const void *P )
{
if ( P )
memory->free( memory, (void*)P );
}