- Fixed: Information added with addkeysection and addmenukey was never freed.

- Fixed: A classic decorate FakeInventory's PickupText was never freed.
- Fixed: Colored lights were never freed.
- Fixed: When a dehacked patch was applied, the dehacked StateMap was never
  freed.
- Removed termdone checks around atterm(S_ClearSoundData) and
  atterm(S_Shutdown) because atterm() already checks for duplicates.
- Fixed: S_ClearSoundData() should unload all sounds before it clears S_sfx.
- Fixed: AltSoundRenderer::LoadSound() didn't check if the sound had already
  been loaded and lost the old sound data if it had been.
- Fixed: FinishDehPatch() needlessly duplicated the new DehackedPickup's name.
- Fixed: PatchStrings() allocated a private string and never freed it.


SVN r183 (trunk)
This commit is contained in:
Randy Heit 2006-06-11 01:06:19 +00:00
parent 9655ee9843
commit 5859aa7194
9 changed files with 102 additions and 48 deletions

View File

@ -1,3 +1,17 @@
June 10, 2006
- Fixed: Information added with addkeysection and addmenukey was never freed.
- Fixed: A classic decorate FakeInventory's PickupText was never freed.
- Fixed: Colored lights were never freed.
- Fixed: When a dehacked patch was applied, the dehacked StateMap was never
freed.
- Removed termdone checks around atterm(S_ClearSoundData) and
atterm(S_Shutdown) because atterm() already checks for duplicates.
- Fixed: S_ClearSoundData() should unload all sounds before it clears S_sfx.
- Fixed: AltSoundRenderer::LoadSound() didn't check if the sound had already
been loaded and lost the old sound data if it had been.
- Fixed: FinishDehPatch() needlessly duplicated the new DehackedPickup's name.
- Fixed: PatchStrings() allocated a private string and never freed it.
June 8, 2006 (Changes by Graf Zahl)
- Changed music name handling in MAPINFO so that music can be specified by
full path of a file in a Zip.

View File

@ -692,6 +692,7 @@ CCMD (wdir)
if (wadnum < 0)
{
Printf ("%s must be loaded to view its directory.\n", argv[1]);
return;
}
for (int i = 0; i < Wads.GetNumLumps(); ++i)
{

View File

@ -1935,42 +1935,32 @@ donewithtext:
static int PatchStrings (int dummy)
{
static size_t maxstrlen = 128;
static char *holdstring;
int result;
DPrintf ("[Strings]\n");
if (!holdstring)
holdstring = (char *)M_Malloc (maxstrlen);
while ((result = GetLine()) == 1)
{
*holdstring = '\0';
FString holdstring;
do
{
while (maxstrlen < strlen (holdstring) + strlen (Line2) + 8)
holdstring += skipwhite (Line2);
holdstring.StripRight();
if (holdstring.Len() > 0 && holdstring[holdstring.Len()-1] == '\\')
{
maxstrlen += 128;
holdstring = (char *)M_Realloc (holdstring, maxstrlen);
}
strcat (holdstring, skipwhite (Line2));
stripwhite (holdstring);
if (holdstring[strlen(holdstring)-1] == '\\')
{
holdstring[strlen(holdstring)-1] = '\0';
holdstring.Truncate((long)holdstring.Len()-1);
Line2 = igets ();
} else
}
else
{
Line2 = NULL;
}
} while (Line2 && *Line2);
ReplaceSpecialChars (holdstring);
// [RH] There used to be some code here to add % specifiers to
// obituaries that lacked them for compatibility with old ZDoom
// versions. This code was removed when the string table was
// switched to something completely dynamic.
ReplaceSpecialChars (holdstring.LockBuffer());
holdstring.UnlockBuffer();
GStrings.SetString (Line1, holdstring);
DPrintf ("%s set to:\n%s\n", Line1, holdstring);
DPrintf ("%s set to:\n%s\n", Line1, holdstring.GetChars());
}
return result;
@ -2274,6 +2264,11 @@ static void UnloadDehSupp ()
{
if (--DehUseCount <= 0)
{
// StateMap is not freed here, because if you load a second
// dehacked patch through some means other than including it
// in the first patch, it won't see the state information
// that was altered by the first. So we need to keep the
// StateMap around until all patches have been applied.
DehUseCount = 0;
delete[] DehSuppLump;
DehSuppLump = NULL;
@ -2283,13 +2278,6 @@ static void UnloadDehSupp ()
delete[] OrgSprNames;
OrgSprNames = NULL;
}
/* No! Not if we want to load multiple independant patches!
if (StateMap != NULL)
{
delete[] StateMap;
StateMap = NULL;
}
*/
if (BitNames != NULL)
{
delete[] BitNames;
@ -2531,7 +2519,7 @@ void FinishDehPatch ()
char typeNameBuilder[32];
sprintf (typeNameBuilder, "DehackedPickup%d", touchedIndex);
PClass *subclass = RUNTIME_CLASS(ADehackedPickup)->CreateDerivedClass
(copystring(typeNameBuilder), sizeof(ADehackedPickup));
(typeNameBuilder, sizeof(ADehackedPickup));
AActor *defaults2 = GetDefaultByType (subclass);
memcpy (defaults2, defaults1, sizeof(AActor));
subclass->ActorInfo->GameFilter = type->ActorInfo->GameFilter;
@ -2554,6 +2542,13 @@ void FinishDehPatch ()
// Since deh.MaxHealth was used incorrectly this can only be set
// after finishing with the DEH stuff.
if (deh.MaxHealth == -1) deh.MaxHealth = 100;
// Now that all Dehacked patches have been processed, it's okay to free StateMap.
if (StateMap != NULL)
{
delete[] StateMap;
StateMap = NULL;
}
}
void HandleNoSector()

View File

@ -103,16 +103,16 @@ class AFakeInventory : public AInventory
{
DECLARE_STATELESS_ACTOR (AFakeInventory, AInventory);
public:
char *PickupText;
bool Respawnable;
const char *PickupMessage ()
{
if (PickupText == 0)
const char *text = GetClass()->Meta.GetMetaString (AIMETA_PickupMessage);
if (text == 0)
{
return Super::PickupMessage();
}
return PickupText;
return text;
}
bool ShouldRespawn ()
@ -860,7 +860,7 @@ static void ParseInsideDecoration (FActorInfo *info, AActor *defaults,
else if (def == DEF_Pickup && SC_Compare ("PickupMessage"))
{
SC_MustGetString ();
inv->PickupText = copystring (sc_String);
info->Class->Meta.SetMetaString(AIMETA_PickupMessage, sc_String);
}
else if (def == DEF_Pickup && SC_Compare ("Respawns"))
{

View File

@ -2941,6 +2941,30 @@ void M_SaveCustomKeys (FConfigFile *config, char *section, char *subsection)
static int AddKeySpot;
static void FreeKeySections()
{
const unsigned int numStdControls = countof(ControlsItems);
unsigned int i;
for (i = numStdControls; i < CustomControlsItems.Size(); ++i)
{
menuitem_t *item = &CustomControlsItems[i];
if (item->type == whitetext || item->type == control)
{
if (item->label != NULL)
{
delete[] item->label;
item->label = NULL;
}
if (item->e.command != NULL)
{
delete[] item->e.command;
item->e.command = NULL;
}
}
}
}
CCMD (addkeysection)
{
if (argv.argc() != 3)
@ -2973,6 +2997,7 @@ CCMD (addkeysection)
}
}
atterm (FreeKeySections);
if (i == last)
{ // Add the new section
// Limit the ini name to 32 chars

View File

@ -547,6 +547,13 @@ static void S_ClearSoundData()
{
unsigned int i;
if (GSnd != NULL)
{
for (i = 0; i < S_sfx.Size(); ++i)
{
GSnd->UnloadSound (&S_sfx[i]);
}
}
S_sfx.Clear();
for(i = 0; i < countof(Ambients); i++)
@ -584,14 +591,9 @@ static void S_ClearSoundData()
void S_ParseSndInfo ()
{
static bool termdone=false;
int lump;
if (!termdone)
{
termdone=true;
atterm (S_ClearSoundData);
}
atterm (S_ClearSoundData);
S_ClearSoundData(); // remove old sound data first!
CurrentPitchMask = 0;

View File

@ -280,16 +280,11 @@ void S_AddLocalSndInfo(int lump);
void S_Init ()
{
static bool termdone=false;
int i;
int curvelump;
Printf ("S_Init\n");
if (!termdone)
{
termdone=true;
atterm (S_Shutdown);
}
atterm (S_Shutdown);
// remove old data (S_Init can be called multiple times!)
LastLocalSndInfo = LastLocalSndSeq = "";

View File

@ -632,7 +632,12 @@ void AltSoundRenderer::LoadSound (sfxinfo_t *sfx)
SDWORD len;
BYTE *sfxdata, *sfxstart;
SDWORD size;
if (sfx->data != NULL)
{
return;
}
size = sfx->lumpnum >= 0 ? Wads.LumpLength (sfx->lumpnum) : 0;
if (size == 0)
{

View File

@ -63,6 +63,8 @@ BYTE InverseColormap[NUMCOLORMAPS*256];
BYTE GoldColormap[NUMCOLORMAPS*256];
int Near255;
static void FreeSpecialLights();;
FColorMatcher ColorMatcher;
/* Current color blending values */
@ -337,6 +339,8 @@ void InitPalette ()
bool usingBuild = false;
int lump;
atterm (FreeSpecialLights);
if ((lump = Wads.CheckNumForFullName ("palette.dat")) >= 0 && Wads.LumpLength (lump) >= 768)
{
usingBuild = FixBuildPalette (pal, lump, false);
@ -625,7 +629,7 @@ FDynamicColormap *GetSpecialLights (PalEntry color, PalEntry fade, int desaturat
}
// Not found. Create it.
colormap = new FDynamicColormap;;
colormap = new FDynamicColormap;
colormap->Maps = new BYTE[NUMCOLORMAPS*256];
colormap->Next = NormalLight.Next;
colormap->Color = color;
@ -638,6 +642,19 @@ FDynamicColormap *GetSpecialLights (PalEntry color, PalEntry fade, int desaturat
return colormap;
}
// Free all lights created with GetSpecialLights
static void FreeSpecialLights()
{
FDynamicColormap *colormap, *next;
for (colormap = NormalLight.Next; colormap != NULL; colormap = next)
{
next = colormap->Next;
delete[] colormap->Maps;
delete colormap;
}
}
// Builds NUMCOLORMAPS colormaps lit with the specified color
void FDynamicColormap::BuildLights ()
{