lmem.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. ** $Id: lmem.h,v 1.12 2000/01/13 16:30:47 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 <stdlib.h>
  9. #include "lua.h"
  10. /* memory error messages */
  11. #define codeEM "code size overflow"
  12. #define constantEM "constant table overflow"
  13. #define refEM "reference table overflow"
  14. #define tableEM "table overflow"
  15. #define memEM "not enough memory"
  16. #define arrEM "internal array larger than `int' limit"
  17. void *luaM_realloc (lua_State *L, void *oldblock, unsigned long size);
  18. void *luaM_growaux (lua_State *L, void *block, unsigned long nelems, int inc, int size,
  19. const char *errormsg, unsigned long limit);
  20. #define luaM_free(L, b) luaM_realloc(L, (b), 0)
  21. #define luaM_malloc(L, t) luaM_realloc(L, NULL, (t))
  22. #define luaM_new(L, t) ((t *)luaM_malloc(L, sizeof(t)))
  23. #define luaM_newvector(L, n,t) ((t *)luaM_malloc(L, (n)*sizeof(t)))
  24. #define luaM_growvector(L, v,nelems,inc,t,e,l) \
  25. ((v)=(t *)luaM_growaux(L, v,nelems,inc,sizeof(t),e,l))
  26. #define luaM_reallocvector(L, v,n,t) ((v)=(t *)luaM_realloc(L, v,(n)*sizeof(t)))
  27. #ifdef DEBUG
  28. extern unsigned long memdebug_numblocks;
  29. extern unsigned long memdebug_total;
  30. extern unsigned long memdebug_maxmem;
  31. #endif
  32. #endif