home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: SysTools / SysTools.zip / ft-beta.zip / freetype / lib / ttmemory.h < prev    next >
C/C++ Source or Header  |  1997-10-06  |  3KB  |  84 lines

  1. /*******************************************************************
  2.  *
  3.  *  ttmemory.h                                               1.2
  4.  *
  5.  *    Memory management component (specification).
  6.  *
  7.  *  Copyright 1996, 1997 by
  8.  *  David Turner, Robert Wilhelm, and Werner Lemberg.
  9.  *
  10.  *  This file is part of the FreeType project, and may only be used
  11.  *  modified and distributed under the terms of the FreeType project
  12.  *  license, LICENSE.TXT. By continuing to use, modify or distribute 
  13.  *  this file you indicate that you have read the license and
  14.  *  understand and accept it fully.
  15.  *
  16.  *  Changes between 1.2 and 1.1 :
  17.  *
  18.  *  - the font pool is gone! All allocations are now performed
  19.  *    with malloc and free.
  20.  *
  21.  *  - introduced the FREE macro and the Free function for
  22.  *    future use in destructors.
  23.  *
  24.  *  - Init_FontPool is now a macro to allow the compilation of
  25.  *    'legacy' applications (all four test programs have been updated).
  26.  *
  27.  ******************************************************************/
  28.  
  29. #ifndef TTMEMORY_H
  30. #define TTMEMORY_H
  31.  
  32. #include "tttypes.h"
  33. #include "string.h"
  34.  
  35.   #ifdef __cplusplus
  36.   extern "C" {
  37.   #endif
  38.  
  39.   #define MEM_Set( dest, byte, count )  memset(dest,byte,count)
  40.  
  41. #ifdef HAVE_MEMCPY
  42.   #define MEM_Copy( dest, source, count )  memcpy(dest,source,count)
  43. #else
  44.   #define MEM_Copy( dest, source, count )  bcopy(source,dest,count )
  45. #endif
  46.  
  47.   #define MEM_Alloc( _pointer_, _size_ )  TT_Alloc(_size_,(void**)&(_pointer_))
  48.   
  49.   #define ALLOC( _pointer_, _size_ ) \
  50.             ( error = MEM_Alloc( _pointer_, _size_ ) )
  51.  
  52.   #define ALLOC_ARRAY( _pointer_, _count_, _type_ ) \
  53.             ( error = MEM_Alloc( _pointer_, (_count_)*sizeof(_type_) ) )
  54.   
  55.   #define FREE( _pointer_ )  TT_Free((void**)&(_pointer_))
  56.   
  57.   TT_Error  TT_Alloc( long  Size, void**  P );
  58.   /* Allocate a block of memory of 'Size' bytes from the heap, and */
  59.   /* sets the pointer '*P' to its address. If 'Size' is 0, or in   */
  60.   /* case of error, the pointer is always set to NULL              */
  61.  
  62.   TT_Error  TT_Free( void**  P );
  63.   /* Releases a block that was previously allocated through Alloc  */
  64.   /* Note that the function returns successfully when P or *P are  */
  65.   /* already NULL. The pointer '*P' is set to NULL on exit in case */
  66.   /* of success..                                                  */
  67.  
  68.   /* for "legacy" applications, that should be re-coded */
  69.   #define Init_FontPool( x, y )  while(0){}
  70.   /* note that this won't release the previously allocated font pool */
  71.   
  72.  
  73.   TT_Error  TTMemory_Init();
  74.   TT_Error  TTMemory_Done();
  75.  
  76.   #ifdef __cplusplus
  77.   }
  78.   #endif
  79.  
  80. #endif /* TTMEMORY_H */
  81.  
  82.  
  83. /* End */
  84.