ref: 7305391e92dc8275758323d06b9b400602a59e72
parent: f4b511d3eb1fe65d51a49c9d56a68610d3f3f25e
author: Simon Howard <[email protected]>
date: Fri Mar 24 14:55:04 EST 2006
Make memblock_t internal to z_zone.c. Adjust Z_ChangeTag #define to cope with this. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 434
--- 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 @@
return W_CacheLumpNum (W_GetNumForName(name), tag);
}
+#if 0
//
// W_Profile
@@ -561,4 +562,6 @@
fclose (f);
}
+
+#endif
--- 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,7 +62,17 @@
#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
{
// total bytes malloced, including header
@@ -442,20 +452,19 @@
//
// 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;
}
--- 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,20 +39,27 @@
//
// 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);
void Z_Free (void *ptr);
@@ -60,31 +67,16 @@
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