Mercurial > vba-clojure
diff src/lua/lmem.h @ 11:27763b933818
raise lua sources up one level
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 11:07:39 -0600 |
parents | src/lua/src/lmem.h@f9f4f1b99eed |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/lua/lmem.h Sat Mar 03 11:07:39 2012 -0600 1.3 @@ -0,0 +1,49 @@ 1.4 +/* 1.5 +** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ 1.6 +** Interface to Memory Manager 1.7 +** See Copyright Notice in lua.h 1.8 +*/ 1.9 + 1.10 +#ifndef lmem_h 1.11 +#define lmem_h 1.12 + 1.13 + 1.14 +#include <stddef.h> 1.15 + 1.16 +#include "llimits.h" 1.17 +#include "lua.h" 1.18 + 1.19 +#define MEMERRMSG "not enough memory" 1.20 + 1.21 + 1.22 +#define luaM_reallocv(L,b,on,n,e) \ 1.23 + ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ 1.24 + luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \ 1.25 + luaM_toobig(L)) 1.26 + 1.27 +#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 1.28 +#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 1.29 +#define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t)) 1.30 + 1.31 +#define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t)) 1.32 +#define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) 1.33 +#define luaM_newvector(L,n,t) \ 1.34 + cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) 1.35 + 1.36 +#define luaM_growvector(L,v,nelems,size,t,limit,e) \ 1.37 + if ((nelems)+1 > (size)) \ 1.38 + ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) 1.39 + 1.40 +#define luaM_reallocvector(L, v,oldn,n,t) \ 1.41 + ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) 1.42 + 1.43 + 1.44 +LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, 1.45 + size_t size); 1.46 +LUAI_FUNC void *luaM_toobig (lua_State *L); 1.47 +LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, 1.48 + size_t size_elem, int limit, 1.49 + const char *errormsg); 1.50 + 1.51 +#endif 1.52 +