Lua 5.1.4: lmem.h


L0001    /*
L0002    ** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
L0003    ** Interface to Memory Manager
L0004    ** See Copyright Notice in lua.h
L0005    */
L0006    
L0007    #ifndef lmem_h
L0008    #define lmem_h
L0009    
L0010    
L0011    #include <stddef.h>
L0012    
L0013    #include "llimits.h"
L0014    #include "lua.h"
L0015    
L0016    #define MEMERRMSG	"not enough memory"
L0017    
L0018    
L0019    #define luaM_reallocv(L,b,on,n,e) \
L0020    	((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ?  /* +1 to avoid warnings */ \
L0021    		luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \
L0022    		luaM_toobig(L))
L0023    
L0024    #define luaM_freemem(L, b, s)	luaM_realloc_(L, (b), (s), 0)
L0025    #define luaM_free(L, b)		luaM_realloc_(L, (b), sizeof(*(b)), 0)
L0026    #define luaM_freearray(L, b, n, t)   luaM_reallocv(L, (b), n, 0, sizeof(t))
L0027    
L0028    #define luaM_malloc(L,t)	luaM_realloc_(L, NULL, 0, (t))
L0029    #define luaM_new(L,t)		cast(t *, luaM_malloc(L, sizeof(t)))
L0030    #define luaM_newvector(L,n,t) \
L0031    		cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t)))
L0032    
L0033    #define luaM_growvector(L,v,nelems,size,t,limit,e) \
L0034              if ((nelems)+1 > (size)) \
L0035                ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e)))
L0036    
L0037    #define luaM_reallocvector(L, v,oldn,n,t) \
L0038       ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
L0039    
L0040    
L0041    LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
L0042                                                              size_t size);
L0043    LUAI_FUNC void *luaM_toobig (lua_State *L);
L0044    LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size,
L0045                                   size_t size_elem, int limit,
L0046                                   const char *errormsg);
L0047    
L0048    #endif
L0049    

Generated by pretty.lua