lmem.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. ** $Id: lmem.h,v 1.5 1997/12/17 20:48:58 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. /* memory error messages */
  10. #define codeEM "code size overflow"
  11. #define constantEM "constant table overflow"
  12. #define refEM "reference table overflow"
  13. #define tableEM "table overflow"
  14. #define memEM "not enough memory"
  15. void *luaM_realloc (void *oldblock, unsigned long size);
  16. int luaM_growaux (void **block, unsigned long nelems, int size,
  17. char *errormsg, unsigned long limit);
  18. #define luaM_free(b) luaM_realloc((b), 0)
  19. #define luaM_malloc(t) luaM_realloc(NULL, (t))
  20. #define luaM_new(t) ((t *)luaM_malloc(sizeof(t)))
  21. #define luaM_newvector(n,t) ((t *)luaM_malloc((n)*sizeof(t)))
  22. #define luaM_growvector(old,n,t,e,l) \
  23. (luaM_growaux((void**)old,n,sizeof(t),e,l))
  24. #define luaM_reallocvector(v,n,t) ((t *)luaM_realloc(v,(n)*sizeof(t)))
  25. #ifdef DEBUG
  26. extern unsigned long numblocks;
  27. extern unsigned long totalmem;
  28. #endif
  29. #endif