lmem.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. ** $Id: lmem.h,v 1.7 1999/02/25 15:16:26 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. #define arrEM "internal array bigger than `int' limit"
  16. void *luaM_realloc (void *oldblock, unsigned long size);
  17. void *luaM_growaux (void *block, unsigned long nelems, int inc, int size,
  18. char *errormsg, unsigned long limit);
  19. #define luaM_free(b) luaM_realloc((b), 0)
  20. #define luaM_malloc(t) luaM_realloc(NULL, (t))
  21. #define luaM_new(t) ((t *)luaM_malloc(sizeof(t)))
  22. #define luaM_newvector(n,t) ((t *)luaM_malloc((n)*sizeof(t)))
  23. #define luaM_growvector(v,nelems,inc,t,e,l) \
  24. ((v)=(t *)luaM_growaux(v,nelems,inc,sizeof(t),e,l))
  25. #define luaM_reallocvector(v,n,t) ((v)=(t *)luaM_realloc(v,(n)*sizeof(t)))
  26. #ifdef DEBUG
  27. extern unsigned long numblocks;
  28. extern unsigned long totalmem;
  29. #endif
  30. #endif