diff options
Diffstat (limited to 'lmem.h')
-rw-r--r-- | lmem.h | 45 |
1 files changed, 45 insertions, 0 deletions
@@ -0,0 +1,45 @@ | |||
1 | /* | ||
2 | ** $Id: $ | ||
3 | ** Interface to Memory Manager | ||
4 | ** See Copyright Notice in lua.h | ||
5 | */ | ||
6 | |||
7 | #ifndef lmem_h | ||
8 | #define lmem_h | ||
9 | |||
10 | |||
11 | #ifndef NULL | ||
12 | #define NULL 0 | ||
13 | #endif | ||
14 | |||
15 | |||
16 | /* memory error messages */ | ||
17 | #define codeEM "code size overflow" | ||
18 | #define symbolEM "symbol table overflow" | ||
19 | #define constantEM "constant table overflow" | ||
20 | #define stackEM "stack size overflow" | ||
21 | #define lexEM "lex buffer overflow" | ||
22 | #define refEM "reference table overflow" | ||
23 | #define tableEM "table overflow" | ||
24 | #define memEM "not enough memory" | ||
25 | |||
26 | void *luaM_buffer (unsigned long size); | ||
27 | void luaM_clearbuffer (void); | ||
28 | void *luaM_realloc (void *oldblock, unsigned long size); | ||
29 | int luaM_growaux (void **block, unsigned long nelems, int size, | ||
30 | char *errormsg, unsigned long limit); | ||
31 | |||
32 | #define luaM_free(b) luaM_realloc((b), 0) | ||
33 | #define luaM_malloc(t) luaM_realloc(NULL, (t)) | ||
34 | #define luaM_new(t) ((t *)luaM_malloc(sizeof(t))) | ||
35 | #define luaM_newvector(n,t) ((t *)luaM_malloc((n)*sizeof(t))) | ||
36 | #define luaM_growvector(old,n,t,e,l) \ | ||
37 | (luaM_growaux((void**)old,n,sizeof(t),e,l)) | ||
38 | #define luaM_reallocvector(v,n,t) ((t *)luaM_realloc(v,(n)*sizeof(t))) | ||
39 | |||
40 | |||
41 | void luaM_query (void); /* only ifdef DEBUG */ | ||
42 | |||
43 | |||
44 | #endif | ||
45 | |||