lmem.h 1.1 KB

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