home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / ialloc.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  4.5 KB  |  127 lines

  1. /* Copyright (C) 1989, 1995, 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: ialloc.h,v 1.2 2000/09/19 19:00:41 lpd Exp $ */
  20. /* Interface to Ghostscript interpreter memory allocator */
  21.  
  22. #ifndef ialloc_INCLUDED
  23. #  define ialloc_INCLUDED
  24.  
  25. #include "imemory.h"
  26.  
  27. /*
  28.  * Define the interpreter memory manager instance.
  29.  */
  30. #define gs_imemory (i_ctx_p->memory)
  31. #define idmemory (&gs_imemory)
  32. #define iimemory (gs_imemory.current)
  33. #define imemory ((gs_memory_t *)iimemory)
  34. #define iimemory_local (gs_imemory.space_local)
  35. #define imemory_local ((gs_memory_t *)iimemory_local)
  36. #define iimemory_global (gs_imemory.space_global)
  37. #define imemory_global ((gs_memory_t *)iimemory_global)
  38. #define iimemory_system (gs_imemory.space_system)
  39. #define imemory_system ((gs_memory_t *)iimemory_system)
  40.  
  41. /*
  42.  * Aliases for invoking the standard allocator interface.
  43.  */
  44. #define ialloc_bytes(nbytes, cname)\
  45.   gs_alloc_bytes(imemory, nbytes, cname)
  46. #define ialloc_struct(typ, pstype, cname)\
  47.   gs_alloc_struct(imemory, typ, pstype, cname)
  48. #define ialloc_byte_array(nelts, esize, cname)\
  49.   gs_alloc_byte_array(imemory, nelts, esize, cname)
  50. #define ialloc_struct_array(nelts, typ, pstype, cname)\
  51.   gs_alloc_struct_array(imemory, nelts, typ, pstype, cname)
  52. #define ifree_object(data, cname)\
  53.   gs_free_object(imemory, data, cname)
  54. #define ifree_const_object(data, cname)\
  55.   gs_free_const_object(imemory, data, cname)
  56. #define ialloc_string(nbytes, cname)\
  57.   gs_alloc_string(imemory, nbytes, cname)
  58. #define iresize_string(data, oldn, newn, cname)\
  59.   gs_resize_string(imemory, data, oldn, newn, cname)
  60. #define ifree_string(data, nbytes, cname)\
  61.   gs_free_string(imemory, data, nbytes, cname)
  62. #define ifree_const_string(data, nbytes, cname)\
  63.   gs_free_const_string(imemory, data, nbytes, cname)
  64.  
  65. /* Initialize the interpreter's allocator. */
  66. int ialloc_init(P4(gs_dual_memory_t *, gs_raw_memory_t *, uint, bool));
  67.  
  68. /* ------ Internal routines ------ */
  69.  
  70. /* Reset the request values that identify the cause of a GC. */
  71. void ialloc_reset_requested(P1(gs_dual_memory_t *));
  72.  
  73. /* Validate the contents of memory. */
  74. void ialloc_validate_spaces(P1(const gs_dual_memory_t *));
  75.  
  76. #define ivalidate_spaces() ialloc_validate_spaces(idmemory)
  77.  
  78. /*
  79.  * Local/global VM management.
  80.  */
  81.  
  82. /* Get the space attribute of the current allocator. */
  83. #define ialloc_space(dmem) ((dmem)->current_space)
  84. #define icurrent_space ialloc_space(idmemory)
  85. uint imemory_space(P1(const gs_ref_memory_t *));
  86.  
  87. /* Select the allocation space. */
  88. void ialloc_set_space(P2(gs_dual_memory_t *, uint));
  89.  
  90. /* Get the l_new attribute of an allocator. */
  91. uint imemory_new_mask(P1(const gs_ref_memory_t *));
  92.  
  93. /* Get the save level of an allocator. */
  94. int imemory_save_level(P1(const gs_ref_memory_t *));
  95.  
  96. /*
  97.  * Ref-related facilities.
  98.  */
  99.  
  100. #ifdef r_type            /* i.e., we know about refs */
  101.  
  102. /* Allocate and free ref arrays. */
  103. #define ialloc_ref_array(paref, attrs, nrefs, cname)\
  104.   gs_alloc_ref_array(iimemory, paref, attrs, nrefs, cname)
  105. #define iresize_ref_array(paref, nrefs, cname)\
  106.   gs_resize_ref_array(iimemory, paref, nrefs, cname)
  107. #define ifree_ref_array(paref, cname)\
  108.   gs_free_ref_array(iimemory, paref, cname)
  109.  
  110. /* Allocate a string ref. */
  111. #define ialloc_string_ref(psref, attrs, nbytes, cname)\
  112.   gs_alloc_string_ref(iimemory, psref, attrs, nbytes, cname)
  113.  
  114. /* Make a ref for a newly allocated structure. */
  115. #define make_istruct(pref,attrs,ptr)\
  116.   make_struct(pref, (attrs) | icurrent_space, ptr)
  117. #define make_istruct_new(pref,attrs,ptr)\
  118.   make_struct_new(pref, (attrs) | icurrent_space, ptr)
  119. #define make_iastruct(pref,attrs,ptr)\
  120.   make_astruct(pref, (attrs) | icurrent_space, ptr)
  121. #define make_iastruct_new(pref,attrs,ptr)\
  122.   make_astruct_new(pref, (attrs) | icurrent_space, ptr)
  123.  
  124. #endif /* ifdef r_type */
  125.  
  126. #endif /* ialloc_INCLUDED */
  127.