summaryrefslogtreecommitdiff
path: root/plugins/Db3x_mmap
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-11-19 21:58:13 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-11-19 21:58:13 +0000
commit0fa87a5066e542f1f4aed2a3addcb9a97644e455 (patch)
tree2c9e204e73d680a74262b149218568ad40cb4726 /plugins/Db3x_mmap
parent3ec92e4c6b86dfffb75cdcd22f4053376615a412 (diff)
thanks Pescuma for writing a good comment about the broken resident variables deletion 4 yrs ago :)
git-svn-id: http://svn.miranda-ng.org/main/trunk@2382 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Db3x_mmap')
-rw-r--r--plugins/Db3x_mmap/src/dbsettings.cpp91
1 files changed, 45 insertions, 46 deletions
diff --git a/plugins/Db3x_mmap/src/dbsettings.cpp b/plugins/Db3x_mmap/src/dbsettings.cpp
index 73e2043245..55c43622d4 100644
--- a/plugins/Db3x_mmap/src/dbsettings.cpp
+++ b/plugins/Db3x_mmap/src/dbsettings.cpp
@@ -645,60 +645,59 @@ STDMETHODIMP_(BOOL) CDb3Base::DeleteContactSetting(HANDLE hContact, DBCONTACTGET
return 1;
}
- mir_cslockfull lck(m_csDbAccess);
- ofsModuleName = GetModuleNameOfs(dbcgs->szModule);
- if (hContact == 0)
- hContact = (HANDLE)m_dbHeader.ofsUser;
-
- dbc = (DBContact*)DBRead(hContact,sizeof(DBContact),NULL);
- if (dbc->signature != DBCONTACT_SIGNATURE)
- return 1;
+ szCachedSettingName = m_cache->GetCachedSetting(dbcgs->szModule,dbcgs->szSetting,moduleNameLen,settingNameLen);
+ if (szCachedSettingName[-1] == 0) { // it's not a resident variable
+ mir_cslock lck(m_csDbAccess);
+ ofsModuleName = GetModuleNameOfs(dbcgs->szModule);
+ if (hContact == 0)
+ hContact = (HANDLE)m_dbHeader.ofsUser;
+
+ dbc = (DBContact*)DBRead(hContact,sizeof(DBContact),NULL);
+ if (dbc->signature != DBCONTACT_SIGNATURE)
+ return 1;
- //make sure the module group exists
- ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(dbc,(DWORD)hContact,ofsModuleName);
- if (ofsSettingsGroup == 0)
- return 1;
+ //make sure the module group exists
+ ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(dbc,(DWORD)hContact,ofsModuleName);
+ if (ofsSettingsGroup == 0)
+ return 1;
- //find if the setting exists
- ofsBlobPtr = ofsSettingsGroup+offsetof(DBContactSettings,blob);
- pBlob = (PBYTE)DBRead(ofsBlobPtr,1,&bytesRemaining);
- while (pBlob[0]) {
- NeedBytes(settingNameLen+1);
- if (pBlob[0] == settingNameLen && !memcmp(pBlob+1,dbcgs->szSetting,settingNameLen))
- break;
- NeedBytes(1);
- MoveAlong(pBlob[0]+1);
- NeedBytes(3);
- MoveAlong(1+GetSettingValueLength(pBlob));
- NeedBytes(1);
- }
- if (!pBlob[0]) //setting didn't exist
- return 1;
+ //find if the setting exists
+ ofsBlobPtr = ofsSettingsGroup+offsetof(DBContactSettings,blob);
+ pBlob = (PBYTE)DBRead(ofsBlobPtr,1,&bytesRemaining);
+ while (pBlob[0]) {
+ NeedBytes(settingNameLen+1);
+ if (pBlob[0] == settingNameLen && !memcmp(pBlob+1,dbcgs->szSetting,settingNameLen))
+ break;
+ NeedBytes(1);
+ MoveAlong(pBlob[0]+1);
+ NeedBytes(3);
+ MoveAlong(1+GetSettingValueLength(pBlob));
+ NeedBytes(1);
+ }
+ if (!pBlob[0]) //setting didn't exist
+ return 1;
- //bin it
- int nameLen,valLen;
- DWORD ofsSettingToCut;
- MoveAlong(1+settingNameLen);
- NeedBytes(3);
- nameLen = 1+settingNameLen;
- valLen = 1+GetSettingValueLength(pBlob);
- ofsSettingToCut = ofsBlobPtr-nameLen;
- MoveAlong(valLen);
- NeedBytes(1);
- while (pBlob[0]) {
- MoveAlong(pBlob[0]+1);
+ //bin it
+ int nameLen,valLen;
+ DWORD ofsSettingToCut;
+ MoveAlong(1+settingNameLen);
NeedBytes(3);
- MoveAlong(1+GetSettingValueLength(pBlob));
+ nameLen = 1+settingNameLen;
+ valLen = 1+GetSettingValueLength(pBlob);
+ ofsSettingToCut = ofsBlobPtr-nameLen;
+ MoveAlong(valLen);
NeedBytes(1);
+ while (pBlob[0]) {
+ MoveAlong(pBlob[0]+1);
+ NeedBytes(3);
+ MoveAlong(1+GetSettingValueLength(pBlob));
+ NeedBytes(1);
+ }
+ DBMoveChunk(ofsSettingToCut,ofsSettingToCut+nameLen+valLen,ofsBlobPtr+1-ofsSettingToCut);
+ DBFlush(1);
}
- DBMoveChunk(ofsSettingToCut,ofsSettingToCut+nameLen+valLen,ofsBlobPtr+1-ofsSettingToCut);
- szCachedSettingName = m_cache->GetCachedSetting(dbcgs->szModule,dbcgs->szSetting,moduleNameLen,settingNameLen);
m_cache->GetCachedValuePtr((HANDLE)saveWparam, szCachedSettingName, -1 );
-
- //quit
- DBFlush(1);
- lck.unlock();
//notify
DBCONTACTWRITESETTING dbcws = {0};