Imported from ../lua-3.1.tar.gz.
[lua.git] / src / lmem.h
blob3c63a53486b20693b7b206eeaf5caca6d2c10022
1 /*
2 ** $Id: lmem.h,v 1.5 1997/12/17 20:48:58 roberto Exp $
3 ** Interface to Memory Manager
4 ** See Copyright Notice in lua.h
5 */
7 #ifndef lmem_h
8 #define lmem_h
11 #ifndef NULL
12 #define NULL 0
13 #endif
16 /* memory error messages */
17 #define codeEM "code size overflow"
18 #define constantEM "constant table overflow"
19 #define refEM "reference table overflow"
20 #define tableEM "table overflow"
21 #define memEM "not enough memory"
23 void *luaM_realloc (void *oldblock, unsigned long size);
24 int luaM_growaux (void **block, unsigned long nelems, int size,
25 char *errormsg, unsigned long limit);
27 #define luaM_free(b) luaM_realloc((b), 0)
28 #define luaM_malloc(t) luaM_realloc(NULL, (t))
29 #define luaM_new(t) ((t *)luaM_malloc(sizeof(t)))
30 #define luaM_newvector(n,t) ((t *)luaM_malloc((n)*sizeof(t)))
31 #define luaM_growvector(old,n,t,e,l) \
32 (luaM_growaux((void**)old,n,sizeof(t),e,l))
33 #define luaM_reallocvector(v,n,t) ((t *)luaM_realloc(v,(n)*sizeof(t)))
36 #ifdef DEBUG
37 extern unsigned long numblocks;
38 extern unsigned long totalmem;
39 #endif
42 #endif