diff options
-rw-r--r-- | plugins/Db3x_mmap/src/dbsettings.cpp | 86 |
1 files changed, 44 insertions, 42 deletions
diff --git a/plugins/Db3x_mmap/src/dbsettings.cpp b/plugins/Db3x_mmap/src/dbsettings.cpp index 82f65d627e..a2175e6f8b 100644 --- a/plugins/Db3x_mmap/src/dbsettings.cpp +++ b/plugins/Db3x_mmap/src/dbsettings.cpp @@ -722,56 +722,58 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteContactSetting(MCONTACT contactID, LPCSTR sz }
MCONTACT saveContact = contactID;
- char *szCachedSettingName = m_cache->GetCachedSetting(szModule, szSetting, moduleNameLen, settingNameLen);
- if (szCachedSettingName[-1] == 0) { // it's not a resident variable
+ {
mir_cslock lck(m_csDbAccess);
- DWORD ofsModuleName = GetModuleNameOfs(szModule);
- DWORD ofsContact = GetContactOffset(contactID);
- DBContact *dbc = (DBContact*)DBRead(ofsContact, NULL);
- if (dbc->signature != DBCONTACT_SIGNATURE)
- return 1;
+ char *szCachedSettingName = m_cache->GetCachedSetting(szModule, szSetting, moduleNameLen, settingNameLen);
+ if (szCachedSettingName[-1] == 0) { // it's not a resident variable
+ DWORD ofsModuleName = GetModuleNameOfs(szModule);
+ DWORD ofsContact = GetContactOffset(contactID);
+ DBContact *dbc = (DBContact*)DBRead(ofsContact, NULL);
+ if (dbc->signature != DBCONTACT_SIGNATURE)
+ return 1;
- // make sure the module group exists
- DWORD ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(dbc, ofsModuleName);
- if (ofsSettingsGroup == 0)
- return 1;
+ // make sure the module group exists
+ DWORD ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(dbc, ofsModuleName);
+ if (ofsSettingsGroup == 0)
+ return 1;
- // find if the setting exists
- DWORD ofsBlobPtr = ofsSettingsGroup + offsetof(DBContactSettings, blob);
- int bytesRemaining;
- PBYTE pBlob = (PBYTE)DBRead(ofsBlobPtr, &bytesRemaining);
- while (pBlob[0]) {
- NeedBytes(settingNameLen + 1);
- if (pBlob[0] == settingNameLen && !memcmp(pBlob + 1, 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
+ DWORD ofsBlobPtr = ofsSettingsGroup + offsetof(DBContactSettings, blob);
+ int bytesRemaining;
+ PBYTE pBlob = (PBYTE)DBRead(ofsBlobPtr, &bytesRemaining);
+ while (pBlob[0]) {
+ NeedBytes(settingNameLen + 1);
+ if (pBlob[0] == settingNameLen && !memcmp(pBlob + 1, 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
- MoveAlong(1 + settingNameLen);
- NeedBytes(3);
- int nameLen = 1 + settingNameLen;
- int valLen = 1 + GetSettingValueLength(pBlob);
- DWORD ofsSettingToCut = ofsBlobPtr - nameLen;
- MoveAlong(valLen);
- NeedBytes(1);
- while (pBlob[0]) {
- MoveAlong(pBlob[0] + 1);
+ // bin it
+ MoveAlong(1 + settingNameLen);
NeedBytes(3);
- MoveAlong(1 + GetSettingValueLength(pBlob));
+ int nameLen = 1 + settingNameLen;
+ int valLen = 1 + GetSettingValueLength(pBlob);
+ DWORD 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);
- DBFlush(1);
- }
- m_cache->GetCachedValuePtr(saveContact, szCachedSettingName, -1);
+ m_cache->GetCachedValuePtr(saveContact, szCachedSettingName, -1);
+ }
// notify
DBCONTACTWRITESETTING dbcws = { 0 };
|