lmem.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. ** $Id: $
  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 symbolEM "symbol table overflow"
  14. #define constantEM "constant table overflow"
  15. #define stackEM "stack size overflow"
  16. #define lexEM "lex buffer overflow"
  17. #define refEM "reference table overflow"
  18. #define tableEM "table overflow"
  19. #define memEM "not enough memory"
  20. void *luaM_buffer (unsigned long size);
  21. void luaM_clearbuffer (void);
  22. void *luaM_realloc (void *oldblock, unsigned long size);
  23. int luaM_growaux (void **block, unsigned long nelems, int size,
  24. char *errormsg, unsigned long limit);
  25. #define luaM_free(b) luaM_realloc((b), 0)
  26. #define luaM_malloc(t) luaM_realloc(NULL, (t))
  27. #define luaM_new(t) ((t *)luaM_malloc(sizeof(t)))
  28. #define luaM_newvector(n,t) ((t *)luaM_malloc((n)*sizeof(t)))
  29. #define luaM_growvector(old,n,t,e,l) \
  30. (luaM_growaux((void**)old,n,sizeof(t),e,l))
  31. #define luaM_reallocvector(v,n,t) ((t *)luaM_realloc(v,(n)*sizeof(t)))
  32. void luaM_query (void); /* only ifdef DEBUG */
  33. #endif