lua/lmem.h

Go to the documentation of this file.
00001 /*
00002 ** $Id: lmem.h,v 1.2 2004/03/23 05:09:14 jbj Exp $
00003 ** Interface to Memory Manager
00004 ** See Copyright Notice in lua.h
00005 */
00006 
00007 #ifndef lmem_h
00008 #define lmem_h
00009 
00010 
00011 #include <stddef.h>
00012 
00013 #include "llimits.h"
00014 #include "lua.h"
00015 
00016 #define MEMERRMSG       "not enough memory"
00017 
00018 
00019 /*@null@*/
00020 void *luaM_realloc (/*@null@*/ lua_State *L, /*@null@*/ void *oldblock, lu_mem oldsize, lu_mem size)
00021         /*@modifies L, oldblock @*/;
00022 
00023 /*@null@*/
00024 void *luaM_growaux (lua_State *L, void *block, int *size, int size_elem,
00025                     int limit, const char *errormsg)
00026         /*@modifies L, block, *size @*/;
00027 
00028 #define luaM_free(L, b, s)      luaM_realloc(L, (b), (s), 0)
00029 #define luaM_freelem(L, b)      luaM_realloc(L, (b), sizeof(*(b)), 0)
00030 #define luaM_freearray(L, b, n, t)      luaM_realloc(L, (b), \
00031                                       cast(lu_mem, n)*cast(lu_mem, sizeof(t)), 0)
00032 
00033 #define luaM_malloc(L, t)       luaM_realloc(L, NULL, 0, (t))
00034 #define luaM_new(L, t)          cast(t *, luaM_malloc(L, sizeof(t)))
00035 #define luaM_newvector(L, n,t)  cast(t *, luaM_malloc(L, \
00036                                          cast(lu_mem, n)*cast(lu_mem, sizeof(t))))
00037 
00038 #define luaM_growvector(L,v,nelems,size,t,limit,e) \
00039           if (((nelems)+1) > (size)) \
00040             ((v)=cast(t *, luaM_growaux(L,v,&(size),sizeof(t),limit,e)))
00041 
00042 #define luaM_reallocvector(L, v,oldn,n,t) \
00043    ((v)=cast(t *, luaM_realloc(L, v,cast(lu_mem, oldn)*cast(lu_mem, sizeof(t)), \
00044                                     cast(lu_mem, n)*cast(lu_mem, sizeof(t)))))
00045 
00046 
00047 #endif
00048 

Generated on Fri Oct 12 08:44:54 2007 for rpm by  doxygen 1.5.2