~ubuntu-branches/ubuntu/oneiric/ghostscript/oneiric

« back to all changes in this revision

Viewing changes to base/gsmemraw.h

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2011-07-15 16:49:55 UTC
  • mfrom: (1.1.23 upstream)
  • Revision ID: james.westby@ubuntu.com-20110715164955-uga6qibao6kez05c
Tags: 9.04~dfsg~20110715-0ubuntu1
* New upstream release
   - GIT snapshot from Jult, 12 2011.
* debian/patches/020110406~a54df2d.patch,
  debian/patches/020110408~0791cc8.patch,
  debian/patches/020110408~507cbee.patch,
  debian/patches/020110411~4509a49.patch,
  debian/patches/020110412~78bb9a6.patch,
  debian/patches/020110418~a05ab8a.patch,
  debian/patches/020110420~20b6c78.patch,
  debian/patches/020110420~4ddefa2.patch: Removed upstream patches.
* debian/rules: Generate ABI version number (variable "abi") correctly,
  cutting off repackaging and pre-release parts.
* debian/rules: Added ./lcms2/ directory to DEB_UPSTREAM_REPACKAGE_EXCLUDES.
* debian/copyright: Added lcms2/* to the list of excluded files.
* debian/symbols.common: Updated for new upstream source. Applied patch
  which dpkg-gensymbols generated for debian/libgs9.symbols to this file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
2
2
   All Rights Reserved.
3
 
  
 
3
 
4
4
   This software is provided AS-IS with no warranty, either express or
5
5
   implied.
6
6
 
11
11
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12
12
*/
13
13
 
14
 
/* $Id: gsmemraw.h 11903 2010-11-16 22:49:26Z ray $ */
 
14
/* $Id$ */
15
15
/* Client interface for "raw memory" allocator */
16
16
 
17
17
/* Initial version 02/03/1998 by John Desrosiers (soho@crl.com) */
22
22
 
23
23
#if 0
24
24
 
25
 
/* gsmemraw was an abstract base class.  
26
 
 * it is no longer in use, instead use the concrete base class is gs_memory_t 
 
25
/* gsmemraw was an abstract base class.
 
26
 * it is no longer in use, instead use the concrete base class is gs_memory_t
27
27
 * since gs_memory_t contains interfaces that must be availiable throughout the system
28
28
 * is is unadvisable to have a class below it without these.
29
29
 */
30
30
 
31
 
 
32
31
/*
33
32
 * This interface provides minimal memory allocation and freeing capability.
34
33
 * It is meant to be used for "wholesale" allocation of blocks -- typically,
95
94
 * actual alignment of the data in memory.
96
95
 */
97
96
 
98
 
                /*
99
 
                 * Allocate bytes.  The bytes are always aligned maximally
100
 
                 * if the processor requires alignment.
101
 
                 *
102
 
                 * Note that the object memory level can allocate bytes as
103
 
                 * either movable or immovable: raw memory blocks are
104
 
                 * always immovable.
105
 
                 */
 
97
                /*
 
98
                 * Allocate bytes.  The bytes are always aligned maximally
 
99
                 * if the processor requires alignment.
 
100
                 *
 
101
                 * Note that the object memory level can allocate bytes as
 
102
                 * either movable or immovable: raw memory blocks are
 
103
                 * always immovable.
 
104
                 */
106
105
 
107
106
#define gs_memory_t_proc_alloc_bytes(proc, mem_t)\
108
107
  byte *proc(mem_t *mem, uint nbytes, client_name_t cname)
110
109
#define gs_alloc_bytes_immovable(mem, nbytes, cname)\
111
110
  ((mem)->procs.alloc_bytes_immovable(mem, nbytes, cname))
112
111
 
113
 
                /*
114
 
                 * Resize an object to a new number of elements.  At the raw
115
 
                 * memory level, the "element" is a byte; for object memory
116
 
                 * (gsmemory.h), the object may be an an array of either
117
 
                 * bytes or structures.  The new size may be larger than,
118
 
                 * the same as, or smaller than the old.  If the new size is
119
 
                 * the same as the old, resize_object returns the same
120
 
                 * object; otherwise, it preserves the first min(old_size,
121
 
                 * new_size) bytes of the object's contents.
122
 
                 */
 
112
                /*
 
113
                 * Resize an object to a new number of elements.  At the raw
 
114
                 * memory level, the "element" is a byte; for object memory
 
115
                 * (gsmemory.h), the object may be an an array of either
 
116
                 * bytes or structures.  The new size may be larger than,
 
117
                 * the same as, or smaller than the old.  If the new size is
 
118
                 * the same as the old, resize_object returns the same
 
119
                 * object; otherwise, it preserves the first min(old_size,
 
120
                 * new_size) bytes of the object's contents.
 
121
                 */
123
122
 
124
123
#define gs_memory_t_proc_resize_object(proc, mem_t)\
125
124
  void *proc(mem_t *mem, void *obj, uint new_num_elements,\
126
 
             client_name_t cname)
 
125
             client_name_t cname)
127
126
 
128
127
#define gs_resize_object(mem, obj, newn, cname)\
129
128
  ((mem)->procs.resize_object(mem, obj, newn, cname))
130
129
 
131
 
                /*
132
 
                 * Free an object (at the object memory level, this includes
133
 
                 * everything except strings).  Note: data == 0 must be
134
 
                 * allowed, and must be a no-op.
135
 
                 */
 
130
                /*
 
131
                 * Free an object (at the object memory level, this includes
 
132
                 * everything except strings).  Note: data == 0 must be
 
133
                 * allowed, and must be a no-op.
 
134
                 */
136
135
 
137
136
#define gs_memory_t_proc_free_object(proc, mem_t)\
138
137
  void proc(mem_t *mem, void *data, client_name_t cname)
140
139
#define gs_free_object(mem, data, cname)\
141
140
  ((mem)->procs.free_object(mem, data, cname))
142
141
 
143
 
                /*
144
 
                 * Report status (assigned, used).
145
 
                 */
 
142
                /*
 
143
                 * Report status (assigned, used).
 
144
                 */
146
145
 
147
146
#define gs_memory_t_proc_status(proc, mem_t)\
148
147
  void proc(mem_t *mem, gs_memory_status_t *status)
150
149
#define gs_memory_status(mem, pst)\
151
150
  ((mem)->procs.status(mem, pst))
152
151
 
153
 
                /*
154
 
                 * Return the stable allocator for this allocator.  The
155
 
                 * stable allocator allocates from the same heap and in
156
 
                 * the same VM space, but is not subject to save and restore.
157
 
                 * (It is the client's responsibility to avoid creating
158
 
                 * dangling pointers.)
159
 
                 *
160
 
                 * Note that the stable allocator may be the same allocator
161
 
                 * as this one.
162
 
                 */
 
152
                /*
 
153
                 * Return the stable allocator for this allocator.  The
 
154
                 * stable allocator allocates from the same heap and in
 
155
                 * the same VM space, but is not subject to save and restore.
 
156
                 * (It is the client's responsibility to avoid creating
 
157
                 * dangling pointers.)
 
158
                 *
 
159
                 * Note that the stable allocator may be the same allocator
 
160
                 * as this one.
 
161
                 */
163
162
 
164
163
#define gs_memory_t_proc_stable(proc, mem_t)\
165
164
  mem_t *proc(mem_t *mem)
167
166
#define gs_memory_stable(mem)\
168
167
  ((mem)->procs.stable(mem))
169
168
 
170
 
                /*
171
 
                 * Free one or more of: data memory acquired by the allocator
172
 
                 * (FREE_ALL_DATA), overhead structures other than the
173
 
                 * allocator itself (FREE_ALL_STRUCTURES), and the allocator
174
 
                 * itself (FREE_ALL_ALLOCATOR).  Note that this requires
175
 
                 * allocators to keep track of all the memory they have ever
176
 
                 * acquired, and where they acquired it.  Note that this
177
 
                 * operation propagates to the stable allocator (if
178
 
                 * different).
179
 
                 */
 
169
                /*
 
170
                 * Free one or more of: data memory acquired by the allocator
 
171
                 * (FREE_ALL_DATA), overhead structures other than the
 
172
                 * allocator itself (FREE_ALL_STRUCTURES), and the allocator
 
173
                 * itself (FREE_ALL_ALLOCATOR).  Note that this requires
 
174
                 * allocators to keep track of all the memory they have ever
 
175
                 * acquired, and where they acquired it.  Note that this
 
176
                 * operation propagates to the stable allocator (if
 
177
                 * different).
 
178
                 */
180
179
 
181
180
#define FREE_ALL_DATA 1
182
181
#define FREE_ALL_STRUCTURES 2
193
192
#define gs_free_all(mem)\
194
193
  gs_memory_free_all(mem, FREE_ALL_DATA, "(free_all)")
195
194
 
196
 
                /*
197
 
                 * Consolidate free space.  This may be used as part of (or
198
 
                 * as an alternative to) garbage collection, or before
199
 
                 * giving up on an attempt to allocate.
200
 
                 */
 
195
                /*
 
196
                 * Consolidate free space.  This may be used as part of (or
 
197
                 * as an alternative to) garbage collection, or before
 
198
                 * giving up on an attempt to allocate.
 
199
                 */
201
200
 
202
201
#define gs_memory_t_proc_consolidate_free(proc, mem_t)\
203
202
  void proc(mem_t *mem)
223
222
    gs_raw_memory_procs(gs_raw_memory_t);
224
223
} gs_raw_memory_procs_t;
225
224
 
226
 
 
227
 
 
228
225
struct gs_raw_memory_s {
229
226
    gs_raw_memory_t *stable_memory;     /* cache the stable allocator */
230
 
    gs_raw_memory_procs_t procs;        
 
227
    gs_raw_memory_procs_t procs;
231
228
};
232
229
 
233
230
#endif /* 0 */