1 // Emacs style mode select   -*- C++ -*-
2 //-----------------------------------------------------------------------------
3 //
4 // $Id: m_alloc.h 4469 2014-01-03 23:38:29Z dr_sean $
5 //
6 // Copyright (C) 1998-2006 by Randy Heit (ZDoom).
7 // Copyright (C) 2006-2014 by The Odamex Team.
8 //
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License
11 // as published by the Free Software Foundation; either version 2
12 // of the License, or (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 // GNU General Public License for more details.
18 //
19 // DESCRIPTION:
20 //	Wrappers around the standard memory allocation routines.
21 //
22 //-----------------------------------------------------------------------------
23 
24 
25 #ifndef __M_ALLOC_H__
26 #define __M_ALLOC_H__
27 
28 #include <stdlib.h>
29 
30 // don't use these, use the macros below instead!
31 void *Malloc (size_t size);
32 void *Calloc (size_t num, size_t size);
33 void *Realloc (void *memblock, size_t size);
34 void M_Free2 (void **memblock);
35 
36 #define M_Malloc(s) Malloc((size_t)s)
37 #define M_Calloc(n,s) Calloc((size_t)n, (size_t)s)
38 #define M_Realloc(p,s) Realloc((void *)p, (size_t)s)
39 
40 #define M_Free(p) \
41     if (1) \
42         M_Free2((void **)&p); \
43     else \
44         (void)0
45 
46 #endif //__M_ALLOC_H__
47 
48 
49