summaryrefslogtreecommitdiff
path: root/plugins/Db3x_mmap/src/dbmodulechain.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-02-19 11:48:12 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-02-19 11:48:12 +0000
commit8dc7456651251bc112b9edd9b5fd1c4849d7c83d (patch)
tree3e2e376197c49e77488c109a129ea269b08cb38f /plugins/Db3x_mmap/src/dbmodulechain.cpp
parent8d428350dc3307f8ada75fafece2049cca84e969 (diff)
import to open a database in read-only mode
git-svn-id: http://svn.miranda-ng.org/main/trunk@8172 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Db3x_mmap/src/dbmodulechain.cpp')
-rw-r--r--plugins/Db3x_mmap/src/dbmodulechain.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/plugins/Db3x_mmap/src/dbmodulechain.cpp b/plugins/Db3x_mmap/src/dbmodulechain.cpp
index bf193717bd..2eedd6653a 100644
--- a/plugins/Db3x_mmap/src/dbmodulechain.cpp
+++ b/plugins/Db3x_mmap/src/dbmodulechain.cpp
@@ -76,21 +76,22 @@ DWORD CDb3Mmap::FindExistingModuleNameOfs(const char *szName)
return 0;
}
-//will create the offset if it needs to
+// will create the offset if it needs to
DWORD CDb3Mmap::GetModuleNameOfs(const char *szName)
{
- struct DBModuleName dbmn;
- int nameLen;
- DWORD ofsNew,ofsExisting;
- char *mod;
+ DWORD ofsExisting = FindExistingModuleNameOfs(szName);
+ if (ofsExisting)
+ return ofsExisting;
- ofsExisting = FindExistingModuleNameOfs(szName);
- if (ofsExisting) return ofsExisting;
+ if (m_bReadOnly)
+ return 0;
- nameLen = (int)strlen(szName);
+ int nameLen = (int)strlen(szName);
- //need to create the module name
- ofsNew = CreateNewSpace(nameLen+offsetof(struct DBModuleName,name));
+ // need to create the module name
+ DWORD ofsNew = CreateNewSpace(nameLen + offsetof(struct DBModuleName, name));
+
+ DBModuleName dbmn;
dbmn.signature = DBMODULENAME_SIGNATURE;
dbmn.cbName = nameLen;
dbmn.ofsNext = m_dbHeader.ofsFirstModuleName;
@@ -100,12 +101,12 @@ DWORD CDb3Mmap::GetModuleNameOfs(const char *szName)
DBWrite(ofsNew + offsetof(struct DBModuleName, name), (PVOID)szName, nameLen);
DBFlush(0);
- //add to cache
- mod = (char*)HeapAlloc(m_hModHeap,0,nameLen+1);
+ // add to cache
+ char *mod = (char*)HeapAlloc(m_hModHeap, 0, nameLen + 1);
strcpy(mod,szName);
AddToList(mod, nameLen, ofsNew);
- //quit
+ // quit
return ofsNew;
}