1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
4
This software is provided AS-IS with no warranty, either express or
7
This software is distributed under license and may not be copied, modified
8
or distributed except as expressly authorized under the terms of that
9
license. Refer to licensing information at http://www.artifex.com/
10
or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
11
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
14
/* $Id: gsmalloc.h 8721 2008-05-09 02:18:14Z ray $ */
15
/* Client interface to default (C heap) allocator */
16
/* Requires gsmemory.h */
18
#ifndef gsmalloc_INCLUDED
19
# define gsmalloc_INCLUDED
23
/* Define a memory manager that allocates directly from the C heap. */
24
typedef struct gs_malloc_block_s gs_malloc_block_t;
25
typedef struct gs_malloc_memory_s {
27
gs_malloc_block_t *allocated;
31
gx_monitor_t *monitor; /* monitor to serialize access to functions */
34
/* Allocate and initialize a malloc memory manager. */
35
gs_malloc_memory_t *gs_malloc_memory_init(void);
37
/* Release all the allocated blocks, and free the memory manager. */
38
/* The cast is unfortunate, but unavoidable. */
39
#define gs_malloc_memory_release(mem)\
40
gs_memory_free_all((gs_memory_t *)mem, FREE_ALL_EVERYTHING,\
41
"gs_malloc_memory_release")
43
gs_memory_t * gs_malloc_init(const gs_memory_t *parent);
44
void gs_malloc_release(gs_memory_t *mem);
46
#define gs_malloc(mem, nelts, esize, cname)\
47
(void *)gs_alloc_byte_array(mem->non_gc_memory, nelts, esize, cname)
48
#define gs_free(mem, data, nelts, esize, cname)\
49
gs_free_object(mem->non_gc_memory, data, cname)
51
/* ---------------- Locking ---------------- */
53
/* Create a locked wrapper for a heap allocator. */
54
int gs_malloc_wrap(gs_memory_t **wrapped, gs_malloc_memory_t *contents);
56
/* Get the wrapped contents. */
57
gs_malloc_memory_t *gs_malloc_wrapped_contents(gs_memory_t *wrapped);
59
/* Free the wrapper, and return the wrapped contents. */
60
gs_malloc_memory_t *gs_malloc_unwrap(gs_memory_t *wrapped);
62
#endif /* gsmalloc_INCLUDED */