Skip to content
Permalink
Browse files

TOOLS: Fix few warnings and memory leaks

  • Loading branch information...
sev- committed Sep 10, 2019
1 parent 2317d8f commit 16f96eb5d84cb846ce503e6f4d88f1c082e49cdf
@@ -260,7 +260,7 @@ void ControlFlow::createGroups() {
setStackLevel(fn->second._v, 0);
ConstInstIterator curInst, nextInst;
nextInst = _insts.begin();
nextInst++;
++nextInst;
int stackLevel = 0;
int expectedStackLevel = 0;
for (curInst = _insts.begin(); nextInst != _insts.end(); ++curInst, ++nextInst) {
@@ -85,7 +85,7 @@ int main(int argc, char** argv) {
std::cout << "Available engines:" << "\n";

std::map<std::string, std::string>::iterator it;
for (it = engines.begin(); it != engines.end(); it++)
for (it = engines.begin(); it != engines.end(); ++it)
std::cout << (*it).first << " " << (*it).second << "\n";

return 0;
@@ -68,7 +68,7 @@ uint32 GroovieJumpInstruction::getDestAddress() const {
while (i != _params.end()) {
if ((*i)->isAddress())
return (*i)->getUnsigned();
i++;
++i;
}
return 0;
}
@@ -70,14 +70,17 @@ void PackBladeRunner::execute() {
mainDir.setFullName("CDFRAMES.DAT");
if (!mainDir.exists()) {
warning("Could not find file %s", mainDir.getName().c_str());
snprintf(fname, 20, "CDFRAMES%d.DAT", curCD);
snprintf(fname, 20, "CDFRAMES%d.DAT", curCD);
mainDir.setFullName(fname);
warning("Retrying for file %s", mainDir.getName().c_str());
}
in.open(mainDir, "rb");

if (!in.isOpen()) {
warning("Cannot open file %s", mainDir.getName().c_str());
free(buf);
free(cdPageOffsets);
free(hdPageOffsets);
return;
}

@@ -31,11 +31,14 @@ PackCge::PackCge(const std::string &name) : Tool(name, TOOLTYPE_EXTRACTION/*TOOL
input.format = "/";
input.file = false;
_inputPaths.push_back(input);

_outputToDirectory = true;

_shorthelp = "Used to repackage Soltys and Sfinx data files.";
_helptext = "\nUsage: " + getName() + " [-o /path/to/output/dir/] /path/to/one_game_file\n";

for (uint i = 0; i < MAX_FILES; i++)
memset(_files[i], 0, kBtKeySize);
}

void PackCge::execute() {
@@ -63,7 +66,7 @@ void PackCge::execute() {

// Handle the old CGE1 format:
verHeader = std::string("CGE1");
if (sversion.compare(verHeader) != 0)
if (sversion.compare(verHeader) != 0)
_fIn.seek(0, SEEK_SET); // So we have to rewind the file, since there's no header.
}

@@ -129,7 +132,7 @@ void PackCge::writeData(Common::File &f, byte *buff, int size) {
void PackCge::pack() {
BtPage btPage;
print("Packing as CGE1...");

/* Build the index page */
// Header
memset(&btPage, 0, sizeof(BtPage));
@@ -200,7 +203,7 @@ void PackCge::pack() {
void PackCge::pack2() {
BtPage2 btPage2;
print("Packing as CGE2...");

/* Build the index page */
// Header
memset(&btPage2, 0, sizeof(BtPage2));
@@ -274,5 +277,3 @@ int main(int argc, char *argv[]) {
return cge.run(argc, argv);
}
#endif


@@ -46,7 +46,7 @@ void ExtractHDB::execute() {
error("Unable to open %s", filename.getFullName().c_str());

Common::File fOut;
for (Common::Array<MPCEntry *>::iterator it = _dir.begin(); it != _dir.end(); it++) {
for (Common::Array<MPCEntry *>::iterator it = _dir.begin(); it != _dir.end(); ++it) {
byte *buffer = (byte *)malloc((*it)->length);

_mpcFile.seek((*it)->offset, SEEK_SET);
@@ -464,6 +464,7 @@ bool Extractor::outputAllFiles(Common::Filename *outputPath) {
printf("OK\n");
} else {
printf("FAILED\n");
fclose(file);
return false;
}
fclose(file);
@@ -496,4 +497,3 @@ bool Extractor::outputFileAs(const char *f, const char *fn) {
fclose(file);
return true;
}

@@ -101,6 +101,8 @@ CompressQueen::CompressQueen(const std::string &name) : CompressionTool(name, TO

_shorthelp = "Used to compress Flight of the Amazon Queen data files.";
_helptext = "\nUsage: " + getName() + " [mode] [mode params] [-o outputdir] <inputfile (queen.1)>\n\t" + _shorthelp + "\n";

_version = NULL;
}

const CompressQueen::GameVersion *CompressQueen::detectGameVersion(uint32 size) {
@@ -328,4 +330,3 @@ int main(int argc, char *argv[]) {
return queen.run(argc, argv);
}
#endif

@@ -114,7 +114,7 @@ bool CompressTonyVDB::convertTonyADPCMSample() {
for (uint32 i = 0; i < _uncompressedSize; i++)
curFileHandle.writeUint16LE(_outBuffer[i]);
curFileHandle.close();

// Encode this raw data...
setRawAudioType(true, false, 16); // LE, stereo, 16-bit
encodeAudio(TEMP_RAW, true, _rate, TEMP_ENC, _format);
@@ -165,6 +165,7 @@ void CompressTonyVDB::execute() {
outpath_enc.setExtension(".FDB");
break;
default:
delete[] vh;
throw ToolException("Unknown audio format");
break;
}
@@ -240,6 +241,8 @@ void CompressTonyVDB::execute() {
/* And some clean-up :-) */
Common::removeFile(TEMP_RAW);
Common::removeFile(TEMP_ENC);

delete[] vh;
}


0 comments on commit 16f96eb

Please sign in to comment.
You can’t perform that action at this time.