- Fixed AInventory::PickupFlash setting with GCC.

- Fixed: The MusicVolumes list was allocated with M_Malloc but freed with
  delete.
- Fixed: demobuffer was inconsistantly handled with new[]/delete[] and
  malloc/free.
- Added used memory tracking to M_Malloc() and M_Realloc(). This
  necessitated the addition of an M_Free() call to track frees.
- Removed M_Calloc since it was only used in one place, and can just as well
  be done with an M_Malloc/memset pair.
- Bumped DEMOGAMEVERSION for the new net controller codes.


SVN r751 (trunk)
This commit is contained in:
Randy Heit 2008-02-17 02:40:03 +00:00
parent 39bff11693
commit 133350fb9c
29 changed files with 193 additions and 109 deletions

View File

@ -1,18 +1,34 @@
February 16, 2008
- Fixed AInventory::PickupFlash setting with GCC.
- Fixed: The MusicVolumes list was allocated with M_Malloc but freed with
delete.
- Fixed: demobuffer was inconsistantly handled with new[]/delete[] and
malloc/free.
- Added used memory tracking to M_Malloc() and M_Realloc(). This
necessitated the addition of an M_Free() call to track frees.
- Removed M_Calloc since it was only used in one place, and can just as well
be done with an M_Malloc/memset pair.
- Bumped DEMOGAMEVERSION for the new net controller codes.
February 16, 2008 (Changes by Graf Zahl)
- Added patch by Karate Chris:
- The net arbitrator can add or remove players to an access list so they
can or cannot control game settings:
* net_addcontroller <player number> - Adds a player to the control list. Only net arbitrators have access to this command.
* net_removecontroller <player number> - Removes a player from the control list. Only net arbitrators have access to this command.
* net_listcontrollers - Lists the players who are able to control the game settings.
- Fixed: The 'Printf'' occurrences in the 'addplayerclass' console command were all missing a '\n' at the end.
- Enhanced the 'playerinfo' console command so more information about each setting is shown.
* net_addcontroller <player number> - Adds a player to the control list.
Only net arbitrators have access to this command.
* net_removecontroller <player number> - Removes a player from the control
list. Only net arbitrators have access to this command.
* net_listcontrollers - Lists the players who are able to control the game
settings.
- Fixed: The 'Printf' occurrences in the 'addplayerclass' console command
were all missing a '\n' at the end.
- Enhanced the 'playerinfo' console command so more information about each
setting is shown.
- Added customizable pickup flash.
- Added option to show shorter messages for save game and screenshot confirmation.
Also added this to the 'Messages' menu.
February 15, 2008
February 14, 2008
- Version bump to 2.2.0.
- Disabled console alpha when the console is fullscreen.
- Re-enabled maybedrawnow for the software renderer. This should be replaced

View File

@ -449,7 +449,7 @@ void C_DeinitConsole ()
{
GameAtExit *next = cmd->Next;
AddCommandString (cmd->Command);
free (cmd);
M_Free (cmd);
cmd = next;
}
@ -1675,7 +1675,7 @@ static bool C_HandleKey (event_t *ev, BYTE *buffer, int len)
if (HistSize == MAXHISTSIZE)
{
HistTail = HistTail->Newer;
free (HistTail->Older);
M_Free (HistTail->Older);
HistTail->Older = NULL;
}
else

View File

@ -233,8 +233,8 @@ missing:
Printf ("Missing argument to %s\n", token);
done:
if (prod2 != NULL) free (prod2);
if (prod1 != NULL) free (prod1);
if (prod2 != NULL) M_Free (prod2);
if (prod1 != NULL) M_Free (prod1);
return prod3;
}
@ -353,7 +353,7 @@ static FStringProd *DoubleToString (FProduction *prod)
sprintf (buf, "%g", static_cast<FDoubleProd *>(prod)->Value);
newprod = NewStringProd (buf);
free (prod);
M_Free (prod);
return newprod;
}
@ -368,7 +368,7 @@ static FDoubleProd *StringToDouble (FProduction *prod)
FDoubleProd *newprod;
newprod = NewDoubleProd (atof (static_cast<FStringProd *>(prod)->Value));
free (prod);
M_Free (prod);
return newprod;
}
@ -746,7 +746,7 @@ CCMD (test)
}
if (prod != NULL)
{
free (prod);
M_Free (prod);
}
}
@ -802,7 +802,7 @@ CCMD (eval)
Printf ("%s\n", static_cast<FStringProd *>(prod)->Value);
}
}
free (prod);
M_Free (prod);
return;
}
}

View File

@ -197,7 +197,7 @@ static struct TicSpecial
{
if (streams[i])
{
free (streams[i]);
M_Free (streams[i]);
streams[i] = NULL;
used[i] = 0;
}

View File

@ -283,7 +283,7 @@ public:
void operator delete (void *mem)
{
free (mem);
M_Free(mem);
}
protected:

View File

@ -305,7 +305,7 @@ void PClass::FreeStateList ()
if (ActorInfo != NULL && ActorInfo->StateList != NULL)
{
ActorInfo->StateList->Destroy();
free (ActorInfo->StateList);
M_Free (ActorInfo->StateList);
ActorInfo->StateList = NULL;
}
}

View File

@ -229,7 +229,10 @@ void FCompressedFile::Close ()
m_File = NULL;
}
if (m_Buffer)
free (m_Buffer);
{
M_Free (m_Buffer);
m_Buffer = NULL;
}
BeEmpty ();
}
@ -372,7 +375,7 @@ void FCompressedFile::Implode ()
memcpy (m_Buffer + 8, compressed, outlen);
if (compressed)
delete[] compressed;
free (oldbuf);
M_Free (oldbuf);
}
void FCompressedFile::Explode ()
@ -396,7 +399,7 @@ void FCompressedFile::Explode ()
r = uncompress (expand, &newlen, m_Buffer + 8, cprlen);
if (r != Z_OK || newlen != expandsize)
{
free (expand);
M_Free (expand);
I_Error ("Could not decompress cfile");
}
}
@ -405,7 +408,7 @@ void FCompressedFile::Explode ()
memcpy (expand, m_Buffer + 8, expandsize);
}
if (FreeOnExplode ())
free (m_Buffer);
M_Free (m_Buffer);
m_Buffer = expand;
m_BufferSize = expandsize;
}
@ -430,7 +433,7 @@ FCompressedMemFile::~FCompressedMemFile ()
{
if (m_ImplodedBuffer != NULL)
{
free (m_ImplodedBuffer);
M_Free (m_ImplodedBuffer);
}
}
@ -672,7 +675,7 @@ FArchive::~FArchive ()
if (m_TypeMap)
delete[] m_TypeMap;
if (m_ObjectMap)
free (m_ObjectMap);
M_Free (m_ObjectMap);
if (m_SpriteMap)
delete[] m_SpriteMap;
}

View File

@ -2436,7 +2436,7 @@ bool G_ProcessIFFDemo (char *mapname)
delete[] uncompressed;
return true;
}
delete[] demobuffer;
M_Free (demobuffer);
zdembodyend = uncompressed + uncompSize;
demobuffer = demo_p = uncompressed;
}
@ -2456,7 +2456,7 @@ void G_DoPlayDemo (void)
if (demolump >= 0)
{
int demolen = Wads.LumpLength (demolump);
demobuffer = new BYTE[demolen];
demobuffer = (BYTE *)M_Malloc(demolen);
Wads.ReadLump (demolump, demobuffer);
}
else
@ -2547,7 +2547,7 @@ bool G_CheckDemoStatus (void)
C_RestoreCVars (); // [RH] Restore cvars demo might have changed
delete[] demobuffer;
M_Free (demobuffer);
demoplayback = false;
netdemo = false;
netgame = false;
@ -2620,7 +2620,7 @@ bool G_CheckDemoStatus (void)
WriteLong (demo_p - demobuffer - 8, &formlen);
M_WriteFile (demoname, demobuffer, demo_p - demobuffer);
free (demobuffer);
M_Free (demobuffer);
demorecording = false;
stoprecording = false;
Printf ("Demo %s recorded\n", demoname);

View File

@ -255,7 +255,7 @@ static void ApplyActorDefault (int defnum, const char *datastr, int dataint)
case ADEF_Inventory_FlagsSet: item->ItemFlags |= dataint; break;
case ADEF_Inventory_FlagsClear: item->ItemFlags &= ~dataint; break;
case ADEF_Inventory_PickupFlash:item->PickupFlash = dataint? fuglyname("PickupFlash") : NULL;
case ADEF_Inventory_PickupFlash:if(dataint) { item->PickupFlash = fuglyname("PickupFlash"); } else { item->PickupFlash = NULL; } break;
case ADEF_Inventory_Amount: item->Amount = dataint; break;
case ADEF_Inventory_RespawnTics:item->RespawnTics = dataint; break;
case ADEF_Inventory_MaxAmount: item->MaxAmount = dataint; break;

View File

@ -1,9 +1,9 @@
/*
** m_alloc.cpp
** Wrappers for the malloc family of functions
** Wrappers for the malloc family of functions that count used bytes.
**
**---------------------------------------------------------------------------
** Copyright 1998-2006 Randy Heit
** Copyright 1998-2008 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
@ -32,39 +32,93 @@
**
*/
#if !defined(_DEBUG) || !defined(_MSC_VER)
#include "i_system.h"
#include "m_alloc.h"
void *M_Malloc (size_t size)
#include "stats.h"
ADD_STAT(mem)
{
void *zone = malloc (size);
if (!zone)
I_FatalError ("Could not malloc %u bytes", size);
return zone;
FString out;
out.Format("Alloc: %uKB", (AllocBytes + 1023) >> 10);
return out;
}
void *M_Calloc (size_t num, size_t size)
{
void *zone = calloc (num, size);
if (!zone)
I_FatalError ("Could not calloc %u bytes", num * size);
return zone;
}
void *M_Realloc (void *memblock, size_t size)
{
void *zone = realloc (memblock, size);
if (!zone)
I_FatalError ("Could not realloc %u bytes", size);
return zone;
}
size_t AllocBytes;
#ifndef _MSC_VER
#define _NORMAL_BLOCK 0
#define _malloc_dbg(s,b,f,l) malloc(s)
#define _realloc_dbg(p,s,b,f,l) realloc(p,s)
#endif
#ifndef _WIN32
#define _msize(p) malloc_usable_size(p) // from glibc/FreeBSD
#else
#include <malloc.h>
#endif
#ifndef _DEBUG
void *M_Malloc(size_t size)
{
void *block = malloc(size);
if (block == NULL)
I_FatalError("Could not malloc %u bytes", size);
AllocBytes += _msize(block);
return block;
}
void *M_Realloc(void *memblock, size_t size)
{
if (memblock != NULL)
{
AllocBytes -= _msize(memblock);
}
void *block = realloc(memblock, size);
if (block == NULL)
{
I_FatalError("Could not realloc %u bytes", size);
}
AllocBytes += _msize(block);
return block;
}
#else
#ifdef _MSC_VER
#include <crtdbg.h>
#endif
void *M_Malloc_Dbg(size_t size, const char *file, int lineno)
{
void *block = _malloc_dbg(size, _NORMAL_BLOCK, file, lineno);
if (block == NULL)
I_FatalError("Could not malloc %u bytes", size);
AllocBytes += _msize(block);
return block;
}
void *M_Realloc_Dbg(void *memblock, size_t size, const char *file, int lineno)
{
if (memblock != NULL)
{
AllocBytes -= _msize(memblock);
}
void *block = _realloc_dbg(memblock, size, _NORMAL_BLOCK, file, lineno);
if (block == NULL)
{
I_FatalError("Could not realloc %u bytes", size);
}
AllocBytes += _msize(block);
return block;
}
#endif
void M_Free (void *block)
{
if (block != NULL)
{
AllocBytes -= _msize(block);
free(block);
}
}

View File

@ -2,7 +2,7 @@
** m_alloc.h
**
**---------------------------------------------------------------------------
** Copyright 1998-2006 Randy Heit
** Copyright 1998-2008 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
@ -34,26 +34,26 @@
#ifndef __M_ALLOC_H__
#define __M_ALLOC_H__
#if !defined(_DEBUG) || !defined(_MSC_VER)
#include <stdlib.h>
// These are the same as the same stdlib functions,
// except they bomb out with an error requester
// except they bomb out with a fatal error
// when they can't get the memory.
void *M_Malloc (size_t size);
void *M_Calloc (size_t num, size_t size);
void *M_Realloc (void *memblock, size_t size);
#if defined(_DEBUG)
#define M_Malloc(s) M_Malloc_Dbg(s, __FILE__, __LINE__)
#define M_Realloc(p,s) M_Realloc_Dbg(p, s, __FILE__, __LINE__)
void *M_Malloc_Dbg (size_t size, const char *file, int lineno);
void *M_Realloc_Dbg (void *memblock, size_t size, const char *file, int lineno);
#else
#include <stdlib.h>
#include <crtdbg.h>
#define M_Malloc(size) malloc(size)
#define M_Calloc(num, size) calloc(num, size)
#define M_Realloc(memblock, size) realloc(memblock, size)
void *M_Malloc (size_t size);
void *M_Realloc (void *memblock, size_t size);
#endif
void M_Free (void *memblock);
// Number of bytes currently allocated through M_Malloc/M_Realloc
extern size_t AllocBytes;
#endif //__M_ALLOC_H__

View File

@ -270,13 +270,13 @@ FName::NameManager::~NameManager()
for (block = Blocks; block != NULL; block = next)
{
next = block->NextBlock;
free (block);
M_Free (block);
}
Blocks = NULL;
if (NameArray != NULL)
{
free (NameArray);
M_Free (NameArray);
NameArray = NULL;
}
NumNames = MaxNames = 0;

View File

@ -3369,7 +3369,7 @@ void P_FreeExtraLevelData()
while (node != NULL)
{
msecnode_t *next = node->m_snext;
free (node);
M_Free (node);
node = next;
}
headsecnode = NULL;

View File

@ -121,8 +121,11 @@ public:
{
for(unsigned i=0;i<Size();i++)
{
if ((*this)[i] != NULL) free((*this)[i]);
(*this)[i]=NULL;
if ((*this)[i] != NULL)
{
M_Free((*this)[i]);
(*this)[i] = NULL;
}
}
}
};

View File

@ -620,7 +620,7 @@ AnimArray::~AnimArray()
{
if ((*this)[i] != NULL)
{
free ((*this)[i]);
M_Free ((*this)[i]);
(*this)[i] = NULL;
}
}

View File

@ -388,14 +388,14 @@ void R_DeinitData ()
// Free openings
if (openings != NULL)
{
free (openings);
M_Free (openings);
openings = NULL;
}
// Free drawsegs
if (drawsegs != NULL)
{
free (drawsegs);
M_Free (drawsegs);
drawsegs = NULL;
}
}

View File

@ -491,7 +491,8 @@ static visplane_t *new_visplane (unsigned hash)
if (check == NULL)
{
check = (visplane_t *)M_Calloc (1, sizeof(*check) + sizeof(*check->top)*(MAXWIDTH*2));
check = (visplane_t *)M_Malloc (sizeof(*check) + sizeof(*check->top)*(MAXWIDTH*2));
memset(check, 0, sizeof(*check) + sizeof(*check->top)*(MAXWIDTH*2));
check->bottom = &check->top[MAXWIDTH+2];
}
else if (NULL == (freetail = freetail->next))
@ -1637,7 +1638,7 @@ bool R_PlaneInitData ()
while (pl)
{
visplane_t *next = pl->next;
free (pl);
M_Free (pl);
pl = next;
}
freetail = NULL;
@ -1650,7 +1651,7 @@ bool R_PlaneInitData ()
while (pl)
{
visplane_t *next = pl->next;
free (pl);
M_Free (pl);
pl = next;
}
}

View File

@ -78,7 +78,7 @@ void FRemapTable::Free()
KillNative();
if (Remap != NULL)
{
free(Remap);
M_Free(Remap);
Remap = NULL;
Palette = NULL;
NumEntries = 0;

View File

@ -778,7 +778,7 @@ static void S_ClearSoundData()
{
FMusicVolume *me = MusicVolumes;
MusicVolumes = me->Next;
delete me;
M_Free(me);
}
S_rnd.Clear();

View File

@ -154,7 +154,7 @@ struct FSoundSequencePtrArray : public TArray<FSoundSequence *>
{
for (unsigned int i = 0; i < Size(); ++i)
{
free ((*this)[i]);
M_Free ((*this)[i]);
}
}
};
@ -463,7 +463,7 @@ void S_ParseSndSeq (int levellump)
{
if (Sequences[i])
{
free(Sequences[i]);
M_Free(Sequences[i]);
}
}
Sequences.Clear();
@ -496,7 +496,7 @@ void S_ParseSndSeq (int levellump)
{
if (Sequences[curseq]->SeqName == seqname)
{
free (Sequences[curseq]);
M_Free (Sequences[curseq]);
Sequences[curseq] = NULL;
break;
}

View File

@ -80,7 +80,7 @@ void FStringTable::FreeData ()
while (entry != NULL)
{
next = entry->Next;
free (entry);
M_Free (entry);
entry = next;
}
}
@ -98,7 +98,7 @@ void FStringTable::FreeNonDehackedStrings ()
if (entry->PassNum != 0)
{
*pentry = next;
free (entry);
M_Free (entry);
}
else
{
@ -254,7 +254,7 @@ void FStringTable::LoadLanguage (int lumpnum, DWORD code, bool exactMatch, int p
if (cmpval == 0 && entry->PassNum >= passnum)
{
*pentry = entry->Next;
free (entry);
M_Free (entry);
entry = NULL;
}
if (entry == NULL || cmpval > 0)
@ -396,6 +396,6 @@ void FStringTable::SetString (const char *name, const char *newString)
{
*pentry = entry;
entry->Next = oentry->Next;
free (oentry);
M_Free (oentry);
}
}

View File

@ -89,7 +89,7 @@ public:
{
DoDelete (0, Count-1);
}
free (Array);
M_Free (Array);
}
DoCopy (other);
}
@ -103,7 +103,7 @@ public:
{
DoDelete (0, Count-1);
}
free (Array);
M_Free (Array);
Array = NULL;
Count = 0;
Most = 0;
@ -178,7 +178,7 @@ public:
{
if (Array != NULL)
{
free (Array);
M_Free (Array);
Array = NULL;
}
}
@ -604,7 +604,7 @@ protected:
Nodes[i].~Node();
}
}
free(Nodes);
M_Free(Nodes);
Nodes = NULL;
Size = 0;
LastFree = NULL;
@ -628,7 +628,7 @@ protected:
nold[i].~Node();
}
}
free(nold);
M_Free(nold);
}
void Rehash()

View File

@ -99,15 +99,15 @@ bool FRawPageTexture::Check(FileReader & data)
}
if (gapAtStart || (x != width))
{
free (foo);
M_Free (foo);
return true;
}
free(foo);
M_Free(foo);
return false;
}
else
{
free (foo);
M_Free (foo);
return true;
}
}

View File

@ -266,7 +266,7 @@ FTexture::Span **FTexture::CreateSpans (const BYTE *pixels) const
void FTexture::FreeSpans (Span **spans) const
{
free (spans);
M_Free (spans);
}
void FTexture::CopyToBlock (BYTE *dest, int dwidth, int dheight, int xpos, int ypos, const BYTE *translation)

View File

@ -401,7 +401,14 @@ static void HandleDeprecatedFlags(AActor *defaults, bool set, int index)
defaults->meleethreshold = set? 196*FRACUNIT : 0;
break;
case 5: // INVENTORY.PICKUPFLASH
static_cast<AInventory*>(defaults)->PickupFlash = set? fuglyname("PickupFlash") : NULL;
if (set)
{
static_cast<AInventory*>(defaults)->PickupFlash = fuglyname("PickupFlash");
}
else
{
static_cast<AInventory*>(defaults)->PickupFlash = NULL;
}
break;
default:
break; // silence GCC

View File

@ -331,7 +331,7 @@ void InstallStates(FActorInfo *info, AActor *defaults)
if (info->StateList != NULL)
{
info->StateList->Destroy();
free(info->StateList);
M_Free(info->StateList);
}
info->StateList = CreateStateLabelList(StateLabels);

View File

@ -64,7 +64,7 @@
// Protocol version used in demos.
// Bump it if you change existing DEM_ commands or add new ones.
// Otherwise, it should be safe to leave it alone.
#define DEMOGAMEVERSION 0x209
#define DEMOGAMEVERSION 0x20A
// Minimum demo version we can play.
// Bump it whenever you change or remove existing DEM_ commands.

View File

@ -228,7 +228,7 @@ void FWadCollection::InitMultipleFiles (wadlist_t **filenames)
DefaultExtension (name, ".wad");
AddFile (name);
free (*filenames);
M_Free (*filenames);
*filenames = next;
// The first two files are always zdoom.wad and the IWAD, which
@ -305,7 +305,7 @@ static DWORD Zip_FindCentralDir(FileReader * fin)
FileSize = fin->Tell();
uMaxBack = MIN<DWORD>(0xffff, FileSize);
buf = (unsigned char*)M_Malloc(BUFREADCOMMENT+4);
buf = (unsigned char*)malloc(BUFREADCOMMENT+4);
if (buf == NULL) return 0;
uBackRead = 4;

View File

@ -1437,7 +1437,7 @@ BYTE *ST_Util_BitsForBitmap (BITMAPINFO *bitmap_info)
void ST_Util_FreeBitmap (BITMAPINFO *bitmap_info)
{
free (bitmap_info);
M_Free (bitmap_info);
}
//==========================================================================