1 /* Emacs style mode select -*- C++ -*-
2 *-----------------------------------------------------------------------------
5 * PrBoom a Doom port merged with LxDoom and LSDLDoom
6 * based on BOOM, a modified and improved DOOM engine
7 * Copyright (C) 1999 by
8 * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
9 * Copyright (C) 1999-2000 by
10 * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
28 * Zone Memory Allocation, perhaps NeXT ObjectiveC inspired.
29 * Remark: this was the only stuff that, according
30 * to John Carmack, might have been useful for
33 * Rewritten by Lee Killough, though, since it was not efficient enough.
35 *---------------------------------------------------------------------*/
41 #define __attribute__(x)
44 // Include system definitions so that prototypes become
45 // active before macro replacements below are in effect.
52 enum {PU_FREE
, PU_STATIC
, PU_SOUND
, PU_MUSIC
, PU_LEVEL
, PU_LEVSPEC
, PU_CACHE
,
53 /* Must always be last -- killough */ PU_MAX
};
55 #define PU_PURGELEVEL PU_CACHE /* First purgable tag's level */
65 void *(Z_Malloc
)(size_t size
, int tag
, void **ptr
DA(const char *, int));
66 void (Z_Free
)(void *ptr
DA(const char *, int));
67 void (Z_FreeTags
)(int lowtag
, int hightag
DA(const char *, int));
68 void (Z_ChangeTag
)(void *ptr
, int tag
DA(const char *, int));
71 void *(Z_Calloc
)(size_t n
, size_t n2
, int tag
, void **user
DA(const char *, int));
72 void *(Z_Realloc
)(void *p
, size_t n
, int tag
, void **user
DA(const char *, int));
73 char *(Z_Strdup
)(const char *s
, int tag
, void **user
DA(const char *, int));
74 void (Z_CheckHeap
)(DAC(const char *,int)); // killough 3/22/98: add file/line info
75 void Z_DumpHistory(char *);
78 /* cph - save space if not debugging, don't require file
79 * and line to memory calls */
80 #define Z_Free(a) (Z_Free) (a, __FILE__,__LINE__)
81 #define Z_FreeTags(a,b) (Z_FreeTags) (a,b, __FILE__,__LINE__)
82 #define Z_ChangeTag(a,b) (Z_ChangeTag)(a,b, __FILE__,__LINE__)
83 #define Z_Malloc(a,b,c) (Z_Malloc) (a,b,c, __FILE__,__LINE__)
84 #define Z_Strdup(a,b,c) (Z_Strdup) (a,b,c, __FILE__,__LINE__)
85 #define Z_Calloc(a,b,c,d) (Z_Calloc) (a,b,c,d,__FILE__,__LINE__)
86 #define Z_Realloc(a,b,c,d) (Z_Realloc) (a,b,c,d,__FILE__,__LINE__)
87 #define Z_CheckHeap() (Z_CheckHeap)(__FILE__,__LINE__)
90 /* cphipps 2001/11/18 -
91 * If we're using memory mapped file access to WADs, we won't need to maintain
92 * our own heap. So we *could* let "normal" malloc users use the libc malloc
93 * directly, for efficiency. Except we do need a wrapper to handle out of memory
94 * errors... damn, ok, we'll leave it for now.
103 #define malloc(n) Z_Malloc(n,PU_STATIC,0)
104 #define free(p) Z_Free(p)
105 #define realloc(p,n) Z_Realloc(p,n,PU_STATIC,0)
106 #define calloc(n1,n2) Z_Calloc(n1,n2,PU_STATIC,0)
109 char *strdup(const char *s
);
111 #define strdup(s) Z_Strdup(s,PU_STATIC,0)
113 void Z_ZoneHistory(char *);
115 extern size_t zone_size
;