summaryrefslogtreecommitdiff
path: root/plugins/Dbx_tree/src
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2013-09-23 15:13:53 +0000
committerKirill Volinsky <mataes2007@gmail.com>2013-09-23 15:13:53 +0000
commit4917567d0e33f20b07b004c368cd66e301115db0 (patch)
treefa841e9647b10bb5a291196bae241974de30f060 /plugins/Dbx_tree/src
parent83181e39a7613a9ed00c6c7ddcbea59a340d491e (diff)
small plugins cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@6193 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dbx_tree/src')
-rw-r--r--plugins/Dbx_tree/src/DataBase.cpp5
-rw-r--r--plugins/Dbx_tree/src/MappedMemory.cpp40
-rw-r--r--plugins/Dbx_tree/src/MappedMemory.h2
3 files changed, 8 insertions, 39 deletions
diff --git a/plugins/Dbx_tree/src/DataBase.cpp b/plugins/Dbx_tree/src/DataBase.cpp
index 37067ff350..451ce89a00 100644
--- a/plugins/Dbx_tree/src/DataBase.cpp
+++ b/plugins/Dbx_tree/src/DataBase.cpp
@@ -150,10 +150,7 @@ int CDataBase::LoadFile(TDBFileType Index)
TGenericFileHeader h;
m_EncryptionManager[Index] = new CEncryptionManager;
- if (CMappedMemory::InitMMAP())
- m_FileAccess[Index] = new CMappedMemory(m_FileName[Index]);
- else
- m_FileAccess[Index] = new CDirectAccess(m_FileName[Index]);
+ m_FileAccess[Index] = new CMappedMemory(m_FileName[Index]);
m_FileAccess[Index]->Read(&h, 0, sizeof(h));
m_EncryptionManager[Index]->InitEncryption(h.Gen.FileEncryption);
diff --git a/plugins/Dbx_tree/src/MappedMemory.cpp b/plugins/Dbx_tree/src/MappedMemory.cpp
index 5a8d264844..7ced28a886 100644
--- a/plugins/Dbx_tree/src/MappedMemory.cpp
+++ b/plugins/Dbx_tree/src/MappedMemory.cpp
@@ -24,32 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "MappedMemory.h"
#include "Logger.h"
-typedef BOOL (WINAPI *TUnmapViewOfFile)(LPCVOID);
-typedef BOOL (WINAPI *TFlushViewOfFile)(LPCVOID, SIZE_T);
-typedef HANDLE (WINAPI *TCreateFileMappingA)(HANDLE, LPSECURITY_ATTRIBUTES, DWORD, DWORD, DWORD, LPCSTR);
-typedef LPVOID (WINAPI *TMapViewOfFile)(HANDLE, DWORD, DWORD, DWORD, SIZE_T);
-
-HMODULE myKernelLib = NULL;
-TUnmapViewOfFile myUnmapViewOfFile = NULL;
-TFlushViewOfFile myFlushViewOfFile = NULL;
-TCreateFileMappingA myCreateFileMappingA = NULL;
-TMapViewOfFile myMapViewOfFile = NULL;
-
-bool CMappedMemory::InitMMAP()
-{
- if (!myKernelLib)
- myKernelLib = GetModuleHandleA("kernel32.dll"); // is always loaded
-
- if (myKernelLib)
- {
- myUnmapViewOfFile = (TUnmapViewOfFile) GetProcAddress(myKernelLib, "UnmapViewOfFile");
- myFlushViewOfFile = (TFlushViewOfFile) GetProcAddress(myKernelLib, "FlushViewOfFile");
- myCreateFileMappingA = (TCreateFileMappingA) GetProcAddress(myKernelLib, "CreateFileMappingA");
- myMapViewOfFile = (TMapViewOfFile) GetProcAddress(myKernelLib, "MapViewOfFile");
- }
-
- return myUnmapViewOfFile && myFlushViewOfFile && myCreateFileMappingA && myMapViewOfFile;
-}
CMappedMemory::CMappedMemory(const TCHAR* FileName)
: CFileAccess(FileName)
{
@@ -85,8 +59,8 @@ CMappedMemory::~CMappedMemory()
{
if (m_Base)
{
- myFlushViewOfFile(m_Base, NULL);
- myUnmapViewOfFile(m_Base);
+ FlushViewOfFile(m_Base, NULL);
+ UnmapViewOfFile(m_Base);
}
if (m_FileMapping)
CloseHandle(m_FileMapping);
@@ -117,8 +91,8 @@ uint32_t CMappedMemory::_SetSize(uint32_t Size)
{
if (m_Base)
{
- myFlushViewOfFile(m_Base, 0);
- myUnmapViewOfFile(m_Base);
+ FlushViewOfFile(m_Base, 0);
+ UnmapViewOfFile(m_Base);
}
if (m_FileMapping)
CloseHandle(m_FileMapping);
@@ -138,7 +112,7 @@ uint32_t CMappedMemory::_SetSize(uint32_t Size)
return 0;
}
- m_FileMapping = myCreateFileMappingA(m_DirectFile, NULL, PAGE_READWRITE, 0, Size, NULL);
+ m_FileMapping = CreateFileMappingA(m_DirectFile, NULL, PAGE_READWRITE, 0, Size, NULL);
if (!m_FileMapping)
{
@@ -146,7 +120,7 @@ uint32_t CMappedMemory::_SetSize(uint32_t Size)
return 0;
}
- m_Base = (uint8_t*) myMapViewOfFile(m_FileMapping, FILE_MAP_ALL_ACCESS, 0, 0, 0);
+ m_Base = (uint8_t*)MapViewOfFile(m_FileMapping, FILE_MAP_ALL_ACCESS, 0, 0, 0);
if (!m_Base)
{
LOGSYS(logERROR, _T("MapViewOfFile failed"));
@@ -163,6 +137,6 @@ void CMappedMemory::_Invalidate(uint32_t Dest, uint32_t Size)
void CMappedMemory::_Flush()
{
- myFlushViewOfFile(m_Base, NULL);
+ FlushViewOfFile(m_Base, NULL);
FlushFileBuffers(m_DirectFile);
}
diff --git a/plugins/Dbx_tree/src/MappedMemory.h b/plugins/Dbx_tree/src/MappedMemory.h
index e66862836e..8b13aa7bd1 100644
--- a/plugins/Dbx_tree/src/MappedMemory.h
+++ b/plugins/Dbx_tree/src/MappedMemory.h
@@ -42,6 +42,4 @@ protected:
public:
CMappedMemory(const TCHAR* FileName);
virtual ~CMappedMemory();
-
- static bool InitMMAP();
};