- two more places where explicit allocations could be replaced.

This commit is contained in:
Christoph Oelckers 2018-12-15 20:40:17 +01:00 committed by drfrag
parent d4611683a6
commit 988e8042bb
2 changed files with 5 additions and 10 deletions

View file

@ -580,23 +580,22 @@ static int SpawnableSort(const void *a, const void *b)
static void DumpClassMap(FClassMap &themap)
{
FClassMap::Iterator it(themap);
FClassMap::Pair *pair, **allpairs;
FClassMap::Pair *pair;
TArray<FClassMap::Pair*> allpairs(themap.CountUsed(), true);
int i = 0;
// Sort into numerical order, since their arrangement in the map can
// be in an unspecified order.
allpairs = new FClassMap::Pair *[themap.CountUsed()];
while (it.NextPair(pair))
{
allpairs[i++] = pair;
}
qsort(allpairs, i, sizeof(*allpairs), SpawnableSort);
qsort(allpairs.Data(), i, sizeof(allpairs[0]), SpawnableSort);
for (int j = 0; j < i; ++j)
{
pair = allpairs[j];
Printf ("%d %s\n", pair->Key, pair->Value->TypeName.GetChars());
}
delete[] allpairs;
}
CCMD(dumpspawnables)

View file

@ -439,12 +439,8 @@ void player_t::SetLogNumber (int num)
}
else
{
int length=Wads.LumpLength(lumpnum);
char *data= new char[length+1];
Wads.ReadLump (lumpnum, data);
data[length]=0;
SetLogText (data);
delete[] data;
auto lump = Wads.ReadLump(lumpnum);
SetLogText (lump.GetString());
}
}