]> git.ipfire.org Git - thirdparty/cups.git/blob - pstoraster/ialloc.h
Import cups.org releases
[thirdparty/cups.git] / pstoraster / ialloc.h
1 /* Copyright (C) 1989, 1995 Aladdin Enterprises. All rights reserved.
2
3 This file is part of GNU Ghostscript.
4
5 GNU Ghostscript is distributed in the hope that it will be useful, but
6 WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
7 to anyone for the consequences of using it or for whether it serves any
8 particular purpose or works at all, unless he says so in writing. Refer
9 to the GNU General Public License for full details.
10
11 Everyone is granted permission to copy, modify and redistribute GNU
12 Ghostscript, but only under the conditions described in the GNU General
13 Public License. A copy of this license is supposed to have been given
14 to you along with GNU Ghostscript so you can know your rights and
15 responsibilities. It should be in a file named COPYING. Among other
16 things, the copyright notice and this notice must be preserved on all
17 copies.
18
19 Aladdin Enterprises supports the work of the GNU Project, but is not
20 affiliated with the Free Software Foundation or the GNU Project. GNU
21 Ghostscript, as distributed by Aladdin Enterprises, does not require any
22 GNU software to build or run it.
23 */
24
25 /*$Id$ */
26 /* Interface to Ghostscript interpreter memory allocator */
27
28 #ifndef ialloc_INCLUDED
29 # define ialloc_INCLUDED
30
31 #include "imemory.h"
32
33 /*
34 * Define the interpreter memory manager instance.
35 */
36 extern gs_dual_memory_t gs_imemory;
37
38 #define idmemory (&gs_imemory)
39 #define iimemory (gs_imemory.current)
40 #define imemory ((gs_memory_t *)iimemory)
41 #define iimemory_local (gs_imemory.space_local)
42 #define imemory_local ((gs_memory_t *)iimemory_local)
43 #define iimemory_global (gs_imemory.space_global)
44 #define imemory_global ((gs_memory_t *)iimemory_global)
45 #define iimemory_system (gs_imemory.space_system)
46 #define imemory_system ((gs_memory_t *)iimemory_system)
47
48 /*
49 * Aliases for invoking the standard allocator interface.
50 */
51 #define ialloc_bytes(nbytes, cname)\
52 gs_alloc_bytes(imemory, nbytes, cname)
53 #define ialloc_struct(typ, pstype, cname)\
54 gs_alloc_struct(imemory, typ, pstype, cname)
55 #define ialloc_byte_array(nelts, esize, cname)\
56 gs_alloc_byte_array(imemory, nelts, esize, cname)
57 #define ialloc_struct_array(nelts, typ, pstype, cname)\
58 gs_alloc_struct_array(imemory, nelts, typ, pstype, cname)
59 #define ifree_object(data, cname)\
60 gs_free_object(imemory, data, cname)
61 #define ialloc_string(nbytes, cname)\
62 gs_alloc_string(imemory, nbytes, cname)
63 #define ifree_string(data, nbytes, cname)\
64 gs_free_string(imemory, data, nbytes, cname)
65
66 /* Initialize the interpreter's allocator. */
67 void ialloc_init(P3(gs_raw_memory_t *, uint, bool));
68
69 /* Resize a string. */
70 #define iresize_string(data, oldn, newn, cname)\
71 gs_resize_string(imemory, data, oldn, newn, cname)
72
73 /* ------ Internal routines ------ */
74
75 /* Reset the request values that identify the cause of a GC. */
76 void ialloc_reset_requested(P1(gs_dual_memory_t *));
77
78 /* Validate the contents of memory. */
79 void ialloc_validate_spaces(P1(const gs_dual_memory_t *));
80
81 #define ivalidate_spaces() ialloc_validate_spaces(idmemory)
82
83 /*
84 * Local/global VM management.
85 */
86
87 /* Get the space attribute of the current allocator. */
88 #define ialloc_space(dmem) ((dmem)->current_space)
89 #define icurrent_space ialloc_space(idmemory)
90 extern uint imemory_space(P1(gs_ref_memory_t *));
91
92 /* Select the allocation space. */
93 void ialloc_set_space(P2(gs_dual_memory_t *, uint));
94
95 /*
96 * Ref-related facilities.
97 */
98
99 #ifdef r_type /* i.e., we know about refs */
100
101 /* Allocate and free ref arrays. */
102 #define ialloc_ref_array(paref, attrs, nrefs, cname)\
103 gs_alloc_ref_array(iimemory, paref, attrs, nrefs, cname)
104 #define iresize_ref_array(paref, nrefs, cname)\
105 gs_resize_ref_array(iimemory, paref, nrefs, cname)
106 #define ifree_ref_array(paref, cname)\
107 gs_free_ref_array(iimemory, paref, cname)
108
109 /* Allocate a string ref. */
110 #define ialloc_string_ref(psref, attrs, nbytes, cname)\
111 gs_alloc_string_ref(iimemory, psref, attrs, nbytes, cname)
112
113 /* Make a ref for a newly allocated structure. */
114 #define make_istruct(pref,attrs,ptr)\
115 make_struct(pref, (attrs) | icurrent_space, ptr)
116 #define make_istruct_new(pref,attrs,ptr)\
117 make_struct_new(pref, (attrs) | icurrent_space, ptr)
118 #define make_iastruct(pref,attrs,ptr)\
119 make_astruct(pref, (attrs) | icurrent_space, ptr)
120 #define make_iastruct_new(pref,attrs,ptr)\
121 make_astruct_new(pref, (attrs) | icurrent_space, ptr)
122
123 #endif /* ifdef r_type */
124
125 #endif /* ialloc_INCLUDED */