1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
/* Copyright (C) 2001-2006 Artifex Software, Inc.
All Rights Reserved.
This software is provided AS-IS with no warranty, either express or
implied.
This software is distributed under license and may not be copied, modified
or distributed except as expressly authorized under the terms of that
license. Refer to licensing information at http://www.artifex.com/
or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
*/
/* $Id$ */
/* Memory allocator extensions for standard allocator */
#ifndef gsalloc_INCLUDED
# define gsalloc_INCLUDED
/* The following should not be needed at this level! */
#ifndef gs_ref_memory_DEFINED
# define gs_ref_memory_DEFINED
typedef struct gs_ref_memory_s gs_ref_memory_t;
#endif
/*
* Define a structure and interface for GC-related allocator state.
*/
typedef struct gs_memory_gc_status_s {
/* Set by client */
long vm_threshold; /* GC interval */
long max_vm; /* maximum allowed allocation */
int *psignal; /* if not NULL, store signal_value */
/* here if we go over the vm_threshold */
int signal_value; /* value to store in *psignal */
bool enabled; /* auto GC enabled if true */
/* Set by allocator */
long requested; /* amount of last failing request */
} gs_memory_gc_status_t;
void gs_memory_gc_status(const gs_ref_memory_t *, gs_memory_gc_status_t *);
void gs_memory_set_gc_status(gs_ref_memory_t *, const gs_memory_gc_status_t *);
void gs_memory_set_vm_threshold(gs_ref_memory_t * mem, long val);
void gs_memory_set_vm_reclaim(gs_ref_memory_t * mem, bool enabled);
/* ------ Initialization ------ */
/*
* Allocate and mostly initialize the state of an allocator (system, global,
* or local). Does not initialize global or space.
*/
gs_ref_memory_t *ialloc_alloc_state(gs_memory_t *, uint);
/*
* Add a chunk to an externally controlled allocator. Such allocators
* allocate all objects as immovable, are not garbage-collected, and
* don't attempt to acquire additional memory (or free chunks) on their own.
*/
int ialloc_add_chunk(gs_ref_memory_t *, ulong, client_name_t);
/* ------ Internal routines ------ */
/* Prepare for a GC. */
void ialloc_gc_prepare(gs_ref_memory_t *);
/* Initialize after a save. */
void ialloc_reset(gs_ref_memory_t *);
/* Initialize after a save or GC. */
void ialloc_reset_free(gs_ref_memory_t *);
/* Set the cached allocation limit of an alloctor from its GC parameters. */
void ialloc_set_limit(gs_ref_memory_t *);
/* Consolidate free objects. */
void ialloc_consolidate_free(gs_ref_memory_t *);
#endif /* gsalloc_INCLUDED */
|