From 4e2993f37025aa4be5c4d2ee5229292ce08941cc Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 20 Aug 2002 01:27:42 +0000 Subject: [PATCH] Don't free m_szFileString twice. Must use delete[] x when x was allocated as an array. No need to check for NULL; "delete NULL" is always OK. (http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.7) Don't depend on the compiler having old-style for scoping rules. Remove extra iCurValueIndex/iCurParamIndex. --- stepmania/src/MsdFile.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/stepmania/src/MsdFile.cpp b/stepmania/src/MsdFile.cpp index b59d6c0550..73fdd86eb2 100644 --- a/stepmania/src/MsdFile.cpp +++ b/stepmania/src/MsdFile.cpp @@ -21,16 +21,12 @@ MsdFile::MsdFile() MsdFile::~MsdFile() { - if( m_szFileString ) - delete m_szFileString; + delete [] m_szFileString; } //returns true if successful, false otherwise bool MsdFile::ReadFile( CString sNewPath ) { - if( m_szFileString ) - delete m_szFileString; - // Get file size in bytes HANDLE hFile = CreateFile( sNewPath, // pointer to name of the file @@ -46,8 +42,7 @@ bool MsdFile::ReadFile( CString sNewPath ) CloseHandle( hFile ); // allocate a string to hold the file - if( m_szFileString ) - delete m_szFileString; + delete [] m_szFileString; m_szFileString = new char[iBufferSize]; FILE* fp = fopen(sNewPath, "r"); @@ -59,8 +54,9 @@ bool MsdFile::ReadFile( CString sNewPath ) ASSERT( iBufferSize > iBytesRead ); m_iNumValues = 0; - - for( int i=0; i