lmem.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. ** $Id: lmem.h,v 1.18 2000/12/26 18:46:09 roberto Exp roberto $
  3. ** Interface to Memory Manager
  4. ** See Copyright Notice in lua.h
  5. */
  6. #ifndef lmem_h
  7. #define lmem_h
  8. #include <stddef.h>
  9. #include "llimits.h"
  10. #include "lua.h"
  11. void *luaM_realloc (lua_State *L, void *oldblock, luint32 oldsize,
  12. luint32 size);
  13. void *luaM_growaux (lua_State *L, void *block, int *size, int size_elem,
  14. int limit, const char *errormsg);
  15. #define luaM_free(L, b, s) luaM_realloc(L, (b), (s), 0)
  16. #define luaM_freelem(L, b, t) luaM_realloc(L, (b), sizeof(t), 0)
  17. #define luaM_freearray(L, b, n, t) luaM_realloc(L, (b), \
  18. ((luint32)(n)*(luint32)sizeof(t)), 0)
  19. #define luaM_malloc(L, t) luaM_realloc(L, NULL, 0, (t))
  20. #define luaM_new(L, t) ((t *)luaM_malloc(L, sizeof(t)))
  21. #define luaM_newvector(L, n,t) ((t *)luaM_malloc(L, \
  22. (luint32)(n)*(luint32)sizeof(t)))
  23. #define luaM_growvector(L,v,nelems,size,t,limit,e) \
  24. if (((nelems)+1) > (size)) \
  25. ((v)=(t *)luaM_growaux(L,v,&(size),sizeof(t),limit,e))
  26. #define luaM_reallocvector(L, v,oldn,n,t) \
  27. ((v)=(t *)luaM_realloc(L, v,(luint32)(oldn)*(luint32)sizeof(t), \
  28. (luint32)(n)*(luint32)sizeof(t)))
  29. #ifdef LUA_DEBUG
  30. extern mem_int memdebug_numblocks;
  31. extern mem_int memdebug_total;
  32. extern mem_int memdebug_maxmem;
  33. extern mem_int memdebug_memlimit;
  34. #endif
  35. #endif