memory.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. Copyright (C) 2004-2005 Michael Liebscher <johnnycanuck@users.sourceforge.net>
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. /*
  16. * memory.h: Memory allocation manager.
  17. *
  18. * Author: Michael Liebscher <johnnycanuck@users.sourceforge.net>
  19. *
  20. */
  21. /*
  22. Notes:
  23. This module is implemented by memory.c.
  24. */
  25. #ifndef __MEMORY_H__
  26. #define __MEMORY_H__
  27. // Use the macros
  28. extern void *Memory_malloc( size_t size );
  29. extern void *Memory_calloc( size_t num, size_t size );
  30. extern void *Memory_realloc( void *memblock, size_t size );
  31. extern void Memory_free( void *memblock );
  32. extern void Memory_outofmem( const char *name, const char *file, W32 line );
  33. #define MM_MALLOC( size ) Memory_malloc( (size) )
  34. #define MM_CALLOC( num, size ) Memory_calloc( (num), (size) )
  35. #define MM_REALLOC( memblock, size ) Memory_realloc( (memblock), (size) )
  36. #define MM_FREE( memblock ) { Memory_free( (memblock) ); ((memblock)) = NULL; }
  37. #define MM_OUTOFMEM( name ) Memory_outofmem( (name), __FILE__, __LINE__ )
  38. #endif /* __MEMORY_H__ */