3 * Store handling for Steel
5 * version 1.00 6 September 1991
7 * © 1991-1998 Straylight
10 /*----- Licensing note ----------------------------------------------------*
12 * This file is part of Straylight's Steel library.
14 * Steel is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2, or (at your option)
19 * Steel is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with Steel. If not, write to the Free Software Foundation,
26 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 typedef unsigned int size_t;
37 typedef void *(*mem_allocProc)(size_t size);
38 typedef void (*mem_freeProc)(void *ptr);
41 * void mem_flexdInit(void)
44 * Initialises flex system. If flex is already initialised, nothing
45 * happens. This call should be used in preference to flex_init().
48 void mem_flexdInit(const char *name, long max);
49 #define mem_flexInit(x) mem_flexdInit(0, 0)
52 * void mem_heapInit(void)
55 * Initialises heap system. If heap is already initialised, nothing
56 * happens. If flex is not initialised, it is initialised for you. This
57 * call should be used in preference to heap_init(). Note that unlike
58 * earlier versioms, this call will NOT set up ArmenLib to use heap by
59 * default. This would be duplicating the functionality of mem_useHeap().
62 void mem_heapInit(void);
65 * void mem_useMalloc(void)
68 * Makes ArmenLib use malloc() etc. for memory allocation.
71 void mem_useMalloc(void);
74 * void mem_useHeap(void)
77 * Makes ArmenLib use heap_alloc() etc. for memory allocation. It is
78 * initialised if necessary.
81 void mem_useHeap(void);
84 * void mem_useUser(mem_allocProc alloc,mem_freeProc free)
87 * Makes ArmenLib use your own user-defined memory allocation procedures.
90 * mem_allocProc alloc == a routine to allocate a block of memory. If a
91 * block of sufficient size cannot be allocated, return 0. Problems
92 * about allocating blocks of 0 size are handled before your routine is
94 * mem_freeProc free == a routine to free a block of memory. A valid
95 * pointer will be passed to your routine.
98 void mem_useUser(mem_allocProc alloc,mem_freeProc free);
101 * void mem_useRMA(void)
104 * Makes ArmenLib use the RMA for memory allocation.
107 void mem_useRMA(void);
110 * void *mem_RMAalloc(size_t size)
113 * Allocates a block of memory from the relocatable module area.
116 * size_t size == the size of the block
119 * A pointer to the block (or 0)
122 void *mem_RMAalloc(size_t size);
125 * void mem_RMAfree(void *ptr)
128 * Frees a block allocated using RMAalloc.
131 * void *ptr == a pointer to the block.
134 void mem_RMAfree(void *ptr);
137 * void *mem_alloc(size_t size)
140 * Allocates a block of memory using malloc (or heap if initialised). If
141 * size is zero, or allocation fails then a NULL pointer is returned.
144 * size_t size == how big you want the block.
147 * A pointer to the block allocated.
150 void *mem_alloc(size_t size);
153 * void mem_free(void *ptr)
156 * Frees a block of memory. It must have been allocated using mem_alloc().
157 * If ptr is NULL, then mem_free() does nothing.
160 * void *ptr == the pointer returned by mem_alloc()
163 void mem_free(void *ptr);
166 * size_t mem_sizeOfBlock(void *ptr)
169 * Returns the allocated size of the block.
172 * void *ptr == the pointer to the block
175 * The size of the block.
178 size_t mem_sizeOfBlock(void *ptr);
181 * void *mem_reAlloc(void *ptr,size_t newSize)
184 * Alters the size of the block given. If the block could not be resized,
185 * its contents are unchanged. Note that the block may move as a result of
189 * void *ptr == a pointer to the block. This may be NULL, in which case,
190 * this call behaves exactly like mem_alloc().
191 * size_t newSize == the new size to make the block. This may be zero, in
192 * which case the block is freed.
195 * A pointer to the block.
198 void *mem_reAlloc(void *ptr,size_t newSize);
201 * void mem_allowFlexBudge(BOOL allow)
204 * A slightly more sensible way to allow flex store to be shunted around.
207 * BOOL allow == whether you want flex store to be shifted around willy-
211 void mem_allowFlexBudge(BOOL allow);