zmem.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. Copyright (C) 2004 Michael Liebscher
  3. Copyright (C) 1997-2001 Id Software, Inc.
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License
  6. as published by the Free Software Foundation; either version 2
  7. of the License, or (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  15. */
  16. /*
  17. * zmem.h: Zone memory management.
  18. *
  19. * Author: Michael Liebscher <johnnycanuck@users.sourceforge.net>
  20. * Date: 2004
  21. *
  22. * Acknowledgement:
  23. * This code was derived from Quake II, and was originally
  24. * written by Id Software, Inc.
  25. *
  26. */
  27. /*
  28. Notes:
  29. This module is implemented by zmem.c
  30. */
  31. #ifndef __ZMEM_H__
  32. #define __ZMEM_H__
  33. #include <stdlib.h>
  34. // memory tags to allow dynamic memory to be cleaned up
  35. #define TAG_GAME 765 /* clear when unloading the dll */
  36. #define TAG_LEVEL 766 /* clear when loading a new level */
  37. #define TAG_LEVEL_SCP 767 /* clear when unloading level script */
  38. typedef struct zhead_s
  39. {
  40. struct zhead_s *prev, *next;
  41. short magic;
  42. short tag; // for group free
  43. int size;
  44. } zhead_t;
  45. extern zhead_t z_chain;
  46. // Returns 0 filled memory block
  47. extern void *Z_Malloc( size_t size );
  48. extern void *Z_TagMalloc( size_t size, int tag );
  49. extern void Z_Free( void *memblock );
  50. extern void Z_FreeTags( int tag );
  51. extern void Z_Stats_f( void );
  52. #endif /* __ZMEM_H__ */