1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-02-07 12:12:23 +01:00

Remove naked new[] in: export

This commit is contained in:
Paul Licameli
2016-04-14 11:56:09 -04:00
parent ea05fac870
commit 9bdc7b2cbf
6 changed files with 25 additions and 42 deletions

View File

@@ -1808,8 +1808,8 @@ ProgressResult ExportMP3::Export(AudacityProject *project,
auto updateResult = ProgressResult::Success;
long bytes;
int bufferSize = exporter.GetOutBufferSize();
unsigned char *buffer = new unsigned char[bufferSize];
size_t bufferSize = std::max(0, exporter.GetOutBufferSize());
ArrayOf<unsigned char> buffer{ bufferSize };
wxASSERT(buffer);
const WaveTrackConstArray waveTracks =
@@ -1854,18 +1854,18 @@ ProgressResult ExportMP3::Export(AudacityProject *project,
if (blockLen < inSamples) {
if (channels > 1) {
bytes = exporter.EncodeRemainder(mixed, blockLen, buffer);
bytes = exporter.EncodeRemainder(mixed, blockLen, buffer.get());
}
else {
bytes = exporter.EncodeRemainderMono(mixed, blockLen, buffer);
bytes = exporter.EncodeRemainderMono(mixed, blockLen, buffer.get());
}
}
else {
if (channels > 1) {
bytes = exporter.EncodeBuffer(mixed, buffer);
bytes = exporter.EncodeBuffer(mixed, buffer.get());
}
else {
bytes = exporter.EncodeBufferMono(mixed, buffer);
bytes = exporter.EncodeBufferMono(mixed, buffer.get());
}
}
@@ -1876,16 +1876,16 @@ ProgressResult ExportMP3::Export(AudacityProject *project,
break;
}
outFile.Write(buffer, bytes);
outFile.Write(buffer.get(), bytes);
updateResult = progress.Update(mixer->MixGetCurrentTime() - t0, t1 - t0);
}
}
bytes = exporter.FinishStream(buffer);
bytes = exporter.FinishStream(buffer.get());
if (bytes) {
outFile.Write(buffer, bytes);
outFile.Write(buffer.get(), bytes);
}
// Write ID3 tag if it was supposed to be at the end of the file
@@ -1908,8 +1908,6 @@ ProgressResult ExportMP3::Export(AudacityProject *project,
// Close the file
outFile.Close();
delete [] buffer;
return updateResult;
}