foxygit / doom Log in
commit 7305391e92dc8275758323d06b9b400602a59e72
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Fri Mar 24 19:55:04 2006 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Fri Mar 24 19:55:04 2006 +0000

    Make memblock_t internal to z_zone.c. Adjust Z_ChangeTag #define to
    cope with this.

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 434
---
 src/w_wad.c  |  7 +++++--
 src/z_zone.c | 27 ++++++++++++++++++---------
 src/z_zone.h | 52 ++++++++++++++++++++++------------------------------
 3 files changed, 45 insertions(+), 41 deletions(-)

diff --git a/src/w_wad.c b/src/w_wad.c
index a7478f8a..86da932d 100644
--- a/src/w_wad.c
+++ b/src/w_wad.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*-
 //-----------------------------------------------------------------------------
 //
-// $Id: w_wad.c 362 2006-02-03 18:41:26Z fraggle $
+// $Id: w_wad.c 434 2006-03-24 19:55:04Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -66,7 +66,7 @@


 static const char
-rcsid[] = "$Id: w_wad.c 362 2006-02-03 18:41:26Z fraggle $";
+rcsid[] = "$Id: w_wad.c 434 2006-03-24 19:55:04Z fraggle $";


 #include <ctype.h>
@@ -499,6 +499,7 @@ W_CacheLumpName
     return W_CacheLumpNum (W_GetNumForName(name), tag);
 }

+#if 0

 //
 // W_Profile
@@ -562,3 +563,5 @@ void W_Profile (void)
 }


+#endif
+
diff --git a/src/z_zone.c b/src/z_zone.c
index 8bb8347a..cee598e0 100644
--- a/src/z_zone.c
+++ b/src/z_zone.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*-
 //-----------------------------------------------------------------------------
 //
-// $Id: z_zone.c 131 2005-09-24 23:45:18Z fraggle $
+// $Id: z_zone.c 434 2006-03-24 19:55:04Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -42,7 +42,7 @@
 //-----------------------------------------------------------------------------

 static const char
-rcsid[] = "$Id: z_zone.c 131 2005-09-24 23:45:18Z fraggle $";
+rcsid[] = "$Id: z_zone.c 434 2006-03-24 19:55:04Z fraggle $";

 #include "z_zone.h"
 #include "i_system.h"
@@ -62,6 +62,16 @@ rcsid[] = "$Id: z_zone.c 131 2005-09-24 23:45:18Z fraggle $";

 #define ZONEID	0x1d4a11

+typedef struct memblock_s
+{
+    int			size;	// including the header and possibly tiny fragments
+    void**		user;
+    int			tag;	// PU_FREE if this is free
+    int			id;	// should be ZONEID
+    struct memblock_s*	next;
+    struct memblock_s*	prev;
+} memblock_t;
+

 typedef struct
 {
@@ -442,20 +452,19 @@ void Z_CheckHeap (void)
 //
 // Z_ChangeTag
 //
-void
-Z_ChangeTag2
-( void*		ptr,
-  int		tag )
+void Z_ChangeTag2(void *ptr, int tag, char *file, int line)
 {
     memblock_t*	block;

-    block = (memblock_t *) ( (byte *)ptr - sizeof(memblock_t));
+    block = (memblock_t *) ((byte *)ptr - sizeof(memblock_t));

     if (block->id != ZONEID)
-        I_Error ("Z_ChangeTag: freed a pointer without ZONEID");
+        I_Error("%s:%i: Z_ChangeTag: block without a ZONEID!",
+                file, line);

     if (tag >= PU_PURGELEVEL && block->user == NULL)
-        I_Error ("Z_ChangeTag: an owner is required for purgable blocks");
+        I_Error("%s:%i: Z_ChangeTag: an owner is required "
+                "for purgable blocks", file, line);

     block->tag = tag;
 }
diff --git a/src/z_zone.h b/src/z_zone.h
index ec58b282..568f46b3 100644
--- a/src/z_zone.h
+++ b/src/z_zone.h
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*-
 //-----------------------------------------------------------------------------
 //
-// $Id: z_zone.h 119 2005-09-22 12:58:46Z fraggle $
+// $Id: z_zone.h 434 2006-03-24 19:55:04Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -39,19 +39,26 @@
 //
 // ZONE MEMORY
 // PU - purge tags.
-// Tags < 100 are not overwritten until freed.
-#define PU_STATIC		1	/* static entire execution time */
-#define PU_SOUND		2	/* static while playing */
-#define PU_MUSIC		3	/* static while playing */
-#define PU_DAVE		4	/* anything else Dave wants static */
-#define PU_FREE         5   /* a free block */
-#define PU_LEVEL		50	/* static until level exited */
-#define PU_LEVSPEC		51      /* a special thinker in a level */

-// Tags >= 100 are purgable whenever needed.
-#define PU_PURGELEVEL	100
-#define PU_CACHE		101
+enum
+{
+    PU_STATIC = 1,                  // static entire execution time
+    PU_SOUND,                       // static while playing
+    PU_MUSIC,                       // static while playing
+    PU_FREE,                        // a free block
+    PU_LEVEL,                       // static until level exited
+    PU_LEVSPEC,                     // a special thinker in a level
+
+    // Tags >= PU_PURGELEVEL are purgable whenever needed.
+
+    PU_PURGELEVEL,
+    PU_CACHE,

+    // Total number of different tag types
+
+    PU_NUM_TAGS
+};
+

 void	Z_Init (void);
 void*	Z_Malloc (int size, int tag, void *ptr);
@@ -60,31 +67,16 @@ void    Z_FreeTags (int lowtag, int hightag);
 void    Z_DumpHeap (int lowtag, int hightag);
 void    Z_FileDumpHeap (FILE *f);
 void    Z_CheckHeap (void);
-void    Z_ChangeTag2 (void *ptr, int tag);
+void    Z_ChangeTag2 (void *ptr, int tag, char *file, int line);
 int     Z_FreeMemory (void);


-typedef struct memblock_s
-{
-    int			size;	// including the header and possibly tiny fragments
-    void**		user;
-    int			tag;	// PU_FREE if this is free
-    int			id;	// should be ZONEID
-    struct memblock_s*	next;
-    struct memblock_s*	prev;
-} memblock_t;
-
 //
 // This is used to get the local FILE:LINE info from CPP
 // prior to really call the function in question.
 //
-#define Z_ChangeTag(p,t) \
-{ \
-      if (( (memblock_t *)( (byte *)(p) - sizeof(memblock_t)))->id!=0x1d4a11) \
-	  I_Error("Z_CT at "__FILE__":%i",__LINE__); \
-	  Z_ChangeTag2(p,t); \
-};
-
+#define Z_ChangeTag(p,t)                                       \
+    Z_ChangeTag2((p), (t), __FILE__, __LINE__)


 #endif