From: <sag...@us...> - 2013-11-15 18:19:15
|
Revision: 3234 http://sourceforge.net/p/modplug/code/3234 Author: saga-games Date: 2013-11-15 18:19:09 +0000 (Fri, 15 Nov 2013) Log Message: ----------- [Ref] Memory-mapped files: Joined Close and Unlock functions. The only place that called Unlock was closing the file afterwards anyway. Modified Paths: -------------- trunk/OpenMPT/mptrack/MemoryMappedFile.cpp trunk/OpenMPT/mptrack/MemoryMappedFile.h trunk/OpenMPT/soundlib/Dlsbank.cpp Modified: trunk/OpenMPT/mptrack/MemoryMappedFile.cpp =================================================================== --- trunk/OpenMPT/mptrack/MemoryMappedFile.cpp 2013-11-15 18:16:14 UTC (rev 3233) +++ trunk/OpenMPT/mptrack/MemoryMappedFile.cpp 2013-11-15 18:19:09 UTC (rev 3234) @@ -42,7 +42,23 @@ void CMappedFile::Close() //----------------------- { - if(m_pData) Unlock(); + // Unlock file + if(m_hFMap) + { + if(m_pData) + { + UnmapViewOfFile(m_pData); + m_pData = nullptr; + } + CloseHandle(m_hFMap); + m_hFMap = nullptr; + } else if(m_pData) + { + free(m_pData); + m_pData = nullptr; + } + + // Close file handle if(m_hFile) { CloseHandle(m_hFile); @@ -124,23 +140,3 @@ { return FileReader(Lock(), GetLength()); } - - -void CMappedFile::Unlock() -//------------------------ -{ - if(m_hFMap) - { - if(m_pData) - { - UnmapViewOfFile(m_pData); - m_pData = nullptr; - } - CloseHandle(m_hFMap); - m_hFMap = nullptr; - } else if(m_pData) - { - free(m_pData); - m_pData = nullptr; - } -} Modified: trunk/OpenMPT/mptrack/MemoryMappedFile.h =================================================================== --- trunk/OpenMPT/mptrack/MemoryMappedFile.h 2013-11-15 18:16:14 UTC (rev 3233) +++ trunk/OpenMPT/mptrack/MemoryMappedFile.h 2013-11-15 18:19:09 UTC (rev 3234) @@ -34,5 +34,4 @@ size_t GetLength(); const void *Lock(); FileReader GetFile(); - void Unlock(); }; Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.cpp 2013-11-15 18:16:14 UTC (rev 3233) +++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2013-11-15 18:19:09 UTC (rev 3234) @@ -1199,8 +1199,6 @@ || ((priff->id_DLS != IFFID_DLS) && (priff->id_DLS != IFFID_MLS) && (priff->id_DLS != IFFID_sfbk)) || (dwMemPos + priff->riff_len > dwMemLength-8)) { - MapFile.Unlock(); - MapFile.Close(); #ifdef DLSBANK_LOG Log("Invalid DLS bank!\n"); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |