mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-26 07:13:49 +01:00
Fix errors
This commit is contained in:
@@ -587,7 +587,7 @@ void AutoSaveFile::CheckSpace(wxMemoryOutputStream & os)
|
||||
size_t origPos = buf->GetIntPosition();
|
||||
char *temp = new char[mAllocSize];
|
||||
buf->Write(temp, mAllocSize);
|
||||
delete temp;
|
||||
delete[] temp;
|
||||
buf->SetIntPosition(origPos);
|
||||
}
|
||||
}
|
||||
@@ -644,33 +644,33 @@ bool AutoSaveFile::Decode(const wxString & fileName)
|
||||
// Close the file so we can reopen it in read/write mode
|
||||
file.Close();
|
||||
|
||||
// Add </project> tag, if necessary
|
||||
// Add </project> tag, if necessary
|
||||
if (!file.Open(fn.GetFullPath(), wxT("r+b")))
|
||||
{
|
||||
// Really shouldn't happen, but let the caller deal with it
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read the last 16 bytes of the file and check if they contain
|
||||
// "</project>" somewhere.
|
||||
const int bufsize = 16;
|
||||
char buf[bufsize + 1];
|
||||
if (file.SeekEnd(-bufsize) != wxInvalidOffset)
|
||||
{
|
||||
if (file.Read(buf, bufsize) == bufsize)
|
||||
{
|
||||
buf[bufsize] = 0;
|
||||
if (strstr(buf, "</project>") == 0)
|
||||
{
|
||||
// End of file does not contain closing </project> tag, so add it
|
||||
if (file.Seek(0, wxFromEnd) != wxInvalidOffset)
|
||||
{
|
||||
strcpy(buf, "</project>\n");
|
||||
file.Write(buf, strlen(buf));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
// Really shouldn't happen, but let the caller deal with it
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read the last 16 bytes of the file and check if they contain
|
||||
// "</project>" somewhere.
|
||||
const int bufsize = 16;
|
||||
char buf[bufsize + 1];
|
||||
if (file.SeekEnd(-bufsize) != wxInvalidOffset)
|
||||
{
|
||||
if (file.Read(buf, bufsize) == bufsize)
|
||||
{
|
||||
buf[bufsize] = 0;
|
||||
if (strstr(buf, "</project>") == 0)
|
||||
{
|
||||
// End of file does not contain closing </project> tag, so add it
|
||||
if (file.Seek(0, wxFromEnd) != wxInvalidOffset)
|
||||
{
|
||||
strcpy(buf, "</project>\n");
|
||||
file.Write(buf, strlen(buf));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
file.Close();
|
||||
|
||||
@@ -682,7 +682,7 @@ bool AutoSaveFile::Decode(const wxString & fileName)
|
||||
|
||||
if (file.Read(buf, len) != len)
|
||||
{
|
||||
delete buf;
|
||||
delete[] buf;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -698,7 +698,7 @@ bool AutoSaveFile::Decode(const wxString & fileName)
|
||||
out.Open(tempName, wxT("wb"));
|
||||
if (!out.IsOpened())
|
||||
{
|
||||
delete buf;
|
||||
delete[] buf;
|
||||
|
||||
wxRemoveFile(tempName);
|
||||
|
||||
@@ -737,7 +737,7 @@ bool AutoSaveFile::Decode(const wxString & fileName)
|
||||
in.Read(name, len);
|
||||
|
||||
mIds[id] = wxString(name, len / sizeof(wxChar));
|
||||
delete name;
|
||||
delete[] name;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -767,7 +767,7 @@ bool AutoSaveFile::Decode(const wxString & fileName)
|
||||
in.Read(val, len);
|
||||
|
||||
out.WriteAttr(mIds[id], wxString(val, len / sizeof(wxChar)));
|
||||
delete val;
|
||||
delete[] val;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -861,7 +861,7 @@ bool AutoSaveFile::Decode(const wxString & fileName)
|
||||
in.Read(val, len);
|
||||
|
||||
out.WriteData(wxString(val, len / sizeof(wxChar)));
|
||||
delete val;
|
||||
delete[] val;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -874,7 +874,7 @@ bool AutoSaveFile::Decode(const wxString & fileName)
|
||||
in.Read(val, len);
|
||||
|
||||
out.Write(wxString(val, len / sizeof(wxChar)));
|
||||
delete val;
|
||||
delete[] val;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -884,7 +884,7 @@ bool AutoSaveFile::Decode(const wxString & fileName)
|
||||
}
|
||||
}
|
||||
|
||||
delete buf;
|
||||
delete[] buf;
|
||||
|
||||
bool error = out.Error();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user