Prepare new maemo release
[maemo-rb.git] / apps / plugins / doom / z_zone.h
blob6ab9bba1067ddccab9be673dc24d2808622dfaf2
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
25 * 02111-1307, USA.
27 * DESCRIPTION:
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
31 * Quake.
33 * Rewritten by Lee Killough, though, since it was not efficient enough.
35 *---------------------------------------------------------------------*/
37 #ifndef __Z_ZONE__
38 #define __Z_ZONE__
40 #ifndef __GNUC__
41 #define __attribute__(x)
42 #endif
44 // Include system definitions so that prototypes become
45 // active before macro replacements below are in effect.
47 #include "plugin.h"
49 // ZONE MEMORY
50 // PU - purge tags.
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 */
57 #ifdef INSTRUMENTED
58 #define DA(x,y) ,x,y
59 #define DAC(x,y) x,y
60 #else
61 #define DA(x,y)
62 #define DAC(x,y) void
63 #endif
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));
69 void (Z_Init)(void);
70 void Z_Close(void);
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 *);
77 #ifdef INSTRUMENTED
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__)
88 #endif
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.
97 #undef malloc
98 #undef free
99 #undef realloc
100 #undef calloc
101 #undef strdup
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)
107 #undef strdup
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;
117 #endif