- Updated Italian strings that someone kindly e-mailed to me.

- The CRT no longer detects any memory leaks when I run to the IWAD picker and quit.
- Fixed: The memory used to hold the path to zdoom.wad/.pk3 was not freed if
  the IWAD picker was cancelled.
- Fixed: Some implementations of cvar->GetGenericRep (CVAR_String) returned a 
  statically allocated string and others returned a dynamically allocated string.
  To be consistant, they should all be static.
- Fixed: DObject also has three static TArrays that should not be explicitly
  initialized: Objects, FreeIndices, and ToDestroy.
- Added a new do-nothing constructor for TArray that can be used for BSS objects
  that are manipulated before startup. Specifically, this was added because
  C_AddTabCommand() is called before main, but the TabCommands constructor is
  called after the array already has over 100 entries in it, orphaning everything
  that was already inserted. And since the code is much nicer-looking now, I didn't
  want to revert to the old non-TArray version.
  
  This could also have been used to fix FName, but I consider the current
  implementation to be better than the old one, so I'm leaving it as-is.
- Fixed: Scanned IWAD paths were not freed if you exited without selecting one.
- Fixed: Dynamically allocated cvars were not freed on exit.
- Fixed: FConfigFile's destructor did not free space used for Values.


SVN r82 (trunk)
This commit is contained in:
Randy Heit 2006-05-06 23:43:44 +00:00
parent 3c9b55d1db
commit abed04ab23
11 changed files with 516 additions and 336 deletions

View file

@ -1,4 +1,27 @@
May 6, 2006
- Updated Italian strings that someone kindly e-mailed to me.
- The CRT no longer detects any memory leaks when I run to the IWAD picker and quit.
- Fixed: The memory used to hold the path to zdoom.wad/.pk3 was not freed if
the IWAD picker was cancelled.
- Fixed: Some implementations of cvar->GetGenericRep (CVAR_String) returned a
statically allocated string and others returned a dynamically allocated string.
To be consistant, they should all be static.
- Fixed: DObject also has three static TArrays that should not be explicitly
initialized: Objects, FreeIndices, and ToDestroy.
- Added a new do-nothing constructor for TArray that can be used for BSS objects
that are manipulated before startup. Specifically, this was added because
C_AddTabCommand() is called before main, but the TabCommands constructor is
called after the array already has over 100 entries in it, orphaning everything
that was already inserted. And since the code is much nicer-looking now, I didn't
want to revert to the old non-TArray version.
This could also have been used to fix FName, but I consider the current
implementation to be better than the old one, so I'm leaving it as-is.
May 5, 2006
- Fixed: Scanned IWAD paths were not freed if you exited without selecting one.
- Fixed: Dynamically allocated cvars were not freed on exit.
- Fixed: FConfigFile's destructor did not free space used for Values.
- Added "DropItem None" as a way for inherited actors to avoid dropping items if
their superclass normally does. This is only needed if somebody dehacks
DeadZombieMan or DeadShotgunGuy.

View file

@ -528,6 +528,21 @@ static void AddLine (const char *text, bool more, int len)
}
}
static char *work = NULL;
static int worklen = 0;
static struct FreeWork
{
~FreeWork()
{
if (work != NULL)
{
free (work);
work = NULL;
}
}
} FreeTheWork;
void AddToConsole (int printlevel, const char *text)
{
static enum
@ -536,8 +551,6 @@ void AddToConsole (int printlevel, const char *text)
APPENDLINE,
REPLACELINE
} addtype = NEWLINE;
static char *work = NULL;
static int worklen = 0;
char *work_p;
char *linestart;
@ -1721,7 +1734,7 @@ struct TabData
}
};
static TArray<TabData> TabCommands;
static TArray<TabData> TabCommands (TArray<TabData>::NoInit);
static int TabPos; // Last TabCommand tabbed to
static int TabStart; // First char in CmdLine to use for tab completion
static int TabSize; // Size of tab string

View file

@ -68,6 +68,22 @@ FBaseCVar *CVars = NULL;
int cvar_defflags;
static struct RuntimeCVarDestroyer
{
~RuntimeCVarDestroyer()
{
FBaseCVar *var, *next;
for (var = CVars; var != NULL; var = next)
{
next = var->m_Next;
if (var->GetFlags() & CVAR_UNSETTABLE)
{
delete var;
}
}
}
} DestroyTheRuntimeCVars;
FBaseCVar::FBaseCVar (const FBaseCVar &var)
{
I_FatalError ("Use of cvar copy constructor");
@ -810,7 +826,7 @@ UCVarValue FStringCVar::GetFavoriteRep (ECVarType *type) const
{
UCVarValue ret;
*type = CVAR_String;
ret.String = copystring (Value);
ret.String = Value;
return ret;
}
@ -823,7 +839,7 @@ UCVarValue FStringCVar::GetFavoriteRepDefault (ECVarType *type) const
{
UCVarValue ret;
*type = CVAR_String;
ret.String = copystring (DefaultValue);
ret.String = DefaultValue;
return ret;
}
@ -890,11 +906,9 @@ UCVarValue FColorCVar::FromInt2 (int value, ECVarType type)
if (type == CVAR_String)
{
UCVarValue ret;
char work[9];
sprintf (work, "%02x %02x %02x",
sprintf (cstrbuf, "%02x %02x %02x",
RPART(value), GPART(value), BPART(value));
ret.String = copystring (work);
ret.String = cstrbuf;
return ret;
}
return FromInt (value, type);

View file

@ -174,6 +174,8 @@ private:
friend void C_SetCVarsToDefaults (void);
friend void FilterCompactCVars (TArray<FBaseCVar *> &cvars, DWORD filter);
friend struct RuntimeCVarDestroyer;
};
class FBoolCVar : public FBaseCVar

View file

@ -85,6 +85,7 @@ FConfigFile::~FConfigFile ()
while (entry != NULL)
{
FConfigEntry *nextentry = entry->Next;
delete[] entry->Value;
delete[] (char *)entry;
entry = nextentry;
}

View file

@ -1477,7 +1477,7 @@ static int CheckIWAD (const char *doomwaddir, WadStuff *wads)
// Search for a pre-defined IWAD
for (i = IWADNames[0] ? 0 : 1; IWADNames[i]; i++)
{
if (wads[i].Path == NULL)
if (wads[i].Path.IsEmpty())
{
sprintf (iwad, "%s%s%s", doomwaddir, slash, IWADNames[i]);
FixPathSeperator (iwad);
@ -1486,7 +1486,7 @@ static int CheckIWAD (const char *doomwaddir, WadStuff *wads)
wads[i].Type = ScanIWAD (iwad);
if (wads[i].Type != NUM_IWAD_TYPES)
{
wads[i].Path = copystring (iwad);
wads[i].Path = iwad;
numfound++;
}
}
@ -1541,7 +1541,7 @@ static int CheckIWADinEnvDir (const char *envname, WadStuff *wads)
//
//==========================================================================
static EIWADType IdentifyVersion (void)
static EIWADType IdentifyVersion (const char *zdoom_wad)
{
WadStuff wads[sizeof(IWADNames)/sizeof(char *)];
size_t foundwads[NUM_IWAD_TYPES] = { 0 };
@ -1658,6 +1658,9 @@ static EIWADType IdentifyVersion (void)
if (pickwad < 0)
exit (0);
// zdoom.pk3 must always be the first file loaded and the IWAD second.
D_AddFile (zdoom_wad);
if (wads[pickwad].Type == IWAD_HexenDK)
{ // load hexen.wad before loading hexdd.wad
D_AddFile (wads[foundwads[IWAD_Hexen]-1].Path);
@ -1680,11 +1683,6 @@ static EIWADType IdentifyVersion (void)
D_AddFile (wads[pickwad].Path);
}
for (i = 0; i < numwads; i++)
{
delete[] wads[i].Path;
}
return wads[pickwad].Type;
}
@ -1927,17 +1925,19 @@ void D_DoomMain (void)
// as it contains magic stuff we need.
wad = BaseFileSearch ("zdoom.pk3", NULL, true);
if (wad)
D_AddFile (wad);
else
if (wad == NULL)
{
I_FatalError ("Cannot find zdoom.pk3");
}
I_SetTitleString (IWADTypeNames[IdentifyVersion ()]);
I_SetTitleString (IWADTypeNames[IdentifyVersion(wad)]);
GameConfig->DoGameSetup (GameNames[gameinfo.gametype]);
// [RH] zvox.wad - A wad I had intended to be automatically generated
// from Q2's pak0.pak so the female and cyborg player could have
// voices. I never got around to writing the utility to do it, though.
// And I probably never will now. But I know at least one person uses
// it for something else, so this gets to stay here.
wad = BaseFileSearch ("zvox.wad", NULL);
if (wad)
D_AddFile (wad);

View file

@ -77,7 +77,7 @@ enum EIWADType
struct WadStuff
{
char *Path;
FString Path;
EIWADType Type;
};

View file

@ -455,9 +455,9 @@ CCMD (dumpclasses)
Printf ("%d classes shown, %d omitted\n", shown, omitted);
}
TArray<DObject *> DObject::Objects;
TArray<size_t> DObject::FreeIndices;
TArray<DObject *> DObject::ToDestroy;
TArray<DObject *> DObject::Objects (TArray<DObject *>::NoInit);
TArray<size_t> DObject::FreeIndices (TArray<size_t>::NoInit);
TArray<DObject *> DObject::ToDestroy (TArray<DObject *>::NoInit);
bool DObject::Inactive;
DObject::DObject ()

View file

@ -73,6 +73,20 @@ template <class T>
class TArray
{
public:
////////
// This is a dummy constructor that does nothing. The purpose of this
// is so you can create a global TArray in the data segment that gets
// used by code before startup without worrying about the constructor
// resetting it after it's already been used. You MUST NOT use it for
// heap- or stack-allocated TArrays.
enum ENoInit
{
NoInit
};
TArray (ENoInit dummy)
{
}
////////
TArray ()
{
Most = 0;
@ -278,7 +292,8 @@ private:
void DoResize ()
{
T *newarray = (T *)M_Malloc (sizeof(T)*Most);
size_t allocsize = sizeof(T)*Most;
T *newarray = (T *)M_Malloc (allocsize);
for (unsigned int i = 0; i < Count; ++i)
{
CopyForTArray (newarray[i], Array[i]);

File diff suppressed because it is too large Load diff

View file

@ -74,9 +74,9 @@ spalhtic.lmp spalhtic.lmp
========
# Language lumps
language.en languages/english-us.txt
language.enu languages/english-us.txt
language.fr languages/french.txt
language.it languages/italian.txt
language.ita languages/italian.txt
========