tralloc.h 773 B

123456789101112131415161718192021222324252627282930313233343536
  1. /* See README.md for documentation
  2. *
  3. * IMPORTANT: Any `ptr` value used *must* be allocated by
  4. * tralloc or you'll run into problems.
  5. */
  6. #ifndef TRALLOC
  7. #define TRALLOC
  8. #include <stdlib.h>
  9. #include <assert.h>
  10. /* num. bytes heap-allocated by tralloc */
  11. size_t tr_siz();
  12. /* the max. number of heap-allocated bytes tralloc will allow */
  13. size_t tr_limit();
  14. /* set the max. number of heap-allocated bytes tralloc will allow, 0 = infinite */
  15. size_t tr_setlimit(size_t n);
  16. /* The number of bytes allocated for `ptr` */
  17. size_t tr_allocsiz(void *ptr);
  18. /* stdlib wrappers
  19. * These behave the same as their stdlib counterparts */
  20. void *tr_malloc(size_t n);
  21. void *tr_calloc(size_t num, size_t n);
  22. void *tr_realloc(void *ptr, size_t n);
  23. void tr_free(void *ptr);
  24. #endif