📄 ftobjs.h
字号:
/***************************************************************************//* *//* ftobjs.h *//* *//* The FreeType private base classes (specification). *//* *//* Copyright 1996-1999 by *//* David Turner, Robert Wilhelm, and Werner Lemberg *//* *//* This file is part of the FreeType project, and may only be used *//* modified and distributed under the terms of the FreeType project *//* license, LICENSE.TXT. By continuing to use, modify, or distribute *//* this file you indicate that you have read the license and *//* understand and accept it fully. *//* *//***************************************************************************/ /*************************************************************************/ /* */ /* This file contains the definition of all internal FreeType classes. */ /* */ /*************************************************************************/#ifndef FTOBJS_H#define FTOBJS_H#include <ftconfig.h>#include <ftsystem.h>#include <ftdriver.h> /*************************************************************************/ /* */ /* Some generic definitions. */ /* */#ifndef TRUE#define TRUE 1#endif#ifndef FALSE#define FALSE 0#endif#ifndef NULL#define NULL (void*)0#endif#ifndef UNUSED#define UNUSED( arg ) ( (void)(arg) )#endif /*************************************************************************/ /* */ /* The min and max functions missing in C. As usual, be careful not to */ /* write things like MIN( a++, b++ ) to avoid side effects. */ /* */#ifndef MIN#define MIN( a, b ) ( (a) < (b) ? (a) : (b) )#endif#ifndef MAX#define MAX( a, b ) ( (a) > (b) ? (a) : (b) )#endif#ifndef ABS#define ABS( a ) ( (a) < 0 ? -(a) : (a) )#endif /*************************************************************************/ /* */ /* <Macro> */ /* FT_SET_ERROR */ /* */ /* <Description> */ /* This macro is used to set an implicit `error' variable to a given */ /* expression's value (usually a function call), and convert it to a */ /* boolean which is set whenever the value is != 0. */ /* */#undef FT_SET_ERROR#define FT_SET_ERROR( expression ) \ ( (error = (expression)) != 0 ) /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /**** ****/ /**** ****/ /**** M E M O R Y ****/ /**** ****/ /**** ****/ /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /* */ /* <Function> */ /* FT_Alloc */ /* */ /* <Description> */ /* Allocates a new block of memory. The returned area is always */ /* zero-filled, this is a strong convention in many FreeType parts. */ /* */ /* <Input> */ /* memory :: A handle to a given `memory object' where allocation */ /* occurs. */ /* */ /* size :: The size in bytes of the block to allocate. */ /* */ /* <Output> */ /* P :: A pointer to the fresh new block. It should be set to */ /* NULL if `size' is 0, or in case of error. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ /* */ BASE_DEF FT_Error FT_Alloc( FT_Memory memory, FT_Long size, void** P ); /*************************************************************************/ /* */ /* <Function> */ /* FT_Realloc */ /* */ /* <Description> */ /* Reallocates a block of memory pointed to by `*P' to `Size' bytes */ /* from the heap, possibly changing `*P'. */ /* */ /* <Input> */ /* memory :: A handle to a given `memory object' where allocation */ /* occurs. */ /* */ /* current :: current block size in bytes */ /* size :: the new block size in bytes */ /* */ /* <InOut> */ /* P :: A pointer to the fresh new block. It should be set to */ /* NULL if `size' is 0, or in case of error. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ /* */ /* <Note> */ /* All callers of FT_Realloc _must_ provide the current block size */ /* as well as the new one. */ /* */ /* When the memory object's flag FT_memory_FLAG_NO_REALLOC is */ /* set, this function will try to emulate a realloc through uses */ /* of FT_Alloc and FT_Free. Otherwise, it will call the memory- */ /* specific "realloc" implementation. */ /* */ /* (Some embedded memorys do not have a working realloc). */ /* */ BASE_DEF FT_Error FT_Realloc( FT_Memory memory, FT_Long current, FT_Long size, void** P ); /*************************************************************************/ /* */ /* <Function> */ /* FT_Free */ /* */ /* <Description> */ /* Releases a given block of memory allocated through FT_Alloc(). */ /* */ /* <Input> */ /* memory :: A handle to a given `memory object' where allocation */ /* occured. */ /* */ /* P :: This is the _address_ of a _pointer_ which points to the */ /* allocated block. It is always set to NULL on exit. */ /* */ /* <Note> */ /* If P or *P are NULL, this function should return successfully. */ /* This is a strong convention within all of FreeType and its */ /* drivers. */ /* */ BASE_DEF void FT_Free( FT_Memory memory, void** P ); /* This include is needed by the MEM_xxx() macros, it should be */ /* available on every platform we know !! */#include <string.h>#define MEM_Set( dest, byte, count ) memset( dest, byte, count )#ifdef HAVE_MEMCPY#define MEM_Copy( dest, source, count ) memcpy( dest, source, count )#else#define MEM_Copy( dest, source, count ) bcopy( source, dest, count )#endif#define MEM_Move( dest, source, count ) memmove( dest, source, count ) /*************************************************************************/ /* */ /* We now support closures to produce completely reentrant code. This */ /* means the allocation functions now takes an additional argument */ /* (`memory'). It is a handle to a given memory object, responsible for */ /* all low-level operations, including memory management and */ /* synchronisation. */ /* */ /* In order to keep our code readable and use the same macros in the */ /* font drivers and the rest of the library, MEM_Alloc(), ALLOC(), and */ /* ALLOC_ARRAY() now use an implicit variable, `memory'. It must be */ /* defined at all locations where a memory operation is queried. */ /* */ /* */ /* Note that ALL memory allocation functions need an IMPLICIT argument */ /* called `memory' to point to the current memory object. */ /* */#define MEM_Alloc( _pointer_, _size_ ) \ FT_Alloc( memory, _size_, (void**)&(_pointer_) )#define MEM_Realloc( _pointer_, _current_, _size_ ) \ FT_Realloc( memory, _current_, _size_, (void**)&(_pointer_) )#define ALLOC( _pointer_, _size_ ) \ FT_SET_ERROR( MEM_Alloc( _pointer_, _size_ ) )#define REALLOC( _pointer_, _current_, _size_ ) \ FT_SET_ERROR( MEM_Realloc( _pointer_, _current_, _size_ ) )#define ALLOC_ARRAY( _pointer_, _count_, _type_ ) \ FT_SET_ERROR( MEM_Alloc( _pointer_, (_count_)*sizeof (_type_) ) )#define REALLOC_ARRAY( _pointer_, _current_, _count_, _type_ ) \ FT_SET_ERROR( MEM_Realloc( _pointer_, (_current_)*sizeof(_type_), \ (_count_)*sizeof(_type_) ) )#define FREE( _pointer_ ) FT_Free( memory, (void**)&(_pointer_) ) /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /**** ****/ /**** ****/ /**** D R I V E R S ****/ /**** ****/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -