lmem.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. ** $Id: lmem.h,v 1.14 2000/05/24 13:54:49 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, lint32 size);
  12. void *luaM_growaux (lua_State *L, void *block, size_t nelems,
  13. int inc, size_t size, const char *errormsg,
  14. size_t limit);
  15. #define luaM_free(L, b) luaM_realloc(L, (b), 0)
  16. #define luaM_malloc(L, t) luaM_realloc(L, NULL, (t))
  17. #define luaM_new(L, t) ((t *)luaM_malloc(L, sizeof(t)))
  18. #define luaM_newvector(L, n,t) ((t *)luaM_malloc(L, (n)*(lint32)sizeof(t)))
  19. #define luaM_growvector(L, v,nelems,inc,t,e,l) \
  20. ((v)=(t *)luaM_growaux(L, v,nelems,inc,sizeof(t),e,l))
  21. #define luaM_reallocvector(L, v,n,t) \
  22. ((v)=(t *)luaM_realloc(L, v,(n)*(lint32)sizeof(t)))
  23. #ifdef DEBUG
  24. extern unsigned long memdebug_numblocks;
  25. extern unsigned long memdebug_total;
  26. extern unsigned long memdebug_maxmem;
  27. extern unsigned long memdebug_memlimit;
  28. #endif
  29. #endif