diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2016-03-16 17:02:41 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2016-03-16 17:02:41 +0000 |
commit | 5dd0f9a66daa0f22818cd5dcdd85c7d33556d904 (patch) | |
tree | b48cf9eb020c1acd610a0642f7895a11d7937ef0 /plugins/Dbx_mdb/src/dbevents.cpp | |
parent | ccd3481caa5dda6816747901108166298c8037d9 (diff) |
dbx_lmdb: small fix
git-svn-id: http://svn.miranda-ng.org/main/trunk@16485 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dbx_mdb/src/dbevents.cpp')
-rw-r--r-- | plugins/Dbx_mdb/src/dbevents.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/plugins/Dbx_mdb/src/dbevents.cpp b/plugins/Dbx_mdb/src/dbevents.cpp index 466cd3b452..ee6c354e84 100644 --- a/plugins/Dbx_mdb/src/dbevents.cpp +++ b/plugins/Dbx_mdb/src/dbevents.cpp @@ -72,10 +72,12 @@ STDMETHODIMP_(MEVENT) CDbxMdb::AddEvent(MCONTACT contactID, DBEVENTINFO *dbei) BYTE *pBlob = dbei->pBlob;
mir_ptr<BYTE> pCryptBlob;
- if (m_bEncrypted) {
+ if (m_bEncrypted)
+ {
size_t len;
BYTE *pResult = m_crypto->encodeBuffer(pBlob, dbe.cbBlob, &len);
- if (pResult != NULL) {
+ if (pResult != nullptr)
+ {
pCryptBlob = pBlob = pResult;
dbe.cbBlob = (DWORD)len;
dbe.flags |= DBEF_ENCRYPTED;
@@ -155,8 +157,8 @@ STDMETHODIMP_(BOOL) CDbxMdb::DeleteEvent(MCONTACT contactID, MEVENT hDbEvent) cc2 = m_cache->GetCachedContact(dbe->contactID);
}
- const auto Snapshot = [&]() { cc->Snapshot(); if (cc2) cc2->Snapshot(); };
- const auto Revert = [&]() { cc->Revert(); if (cc2) cc2->Revert(); };
+ const auto Snapshot = [&cc, &cc2]() { cc->Snapshot(); if (cc2) cc2->Snapshot(); };
+ const auto Revert = [&cc, &cc2]() { cc->Revert(); if (cc2) cc2->Revert(); };
for (Snapshot();; Revert(), Remap())
{
@@ -246,19 +248,18 @@ STDMETHODIMP_(BOOL) CDbxMdb::GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbei) dbei->cbBlob = dbe->cbBlob;
if (bytesToCopy && dbei->pBlob)
{
- BYTE *pSrc = (BYTE*)data.mv_data + sizeof(DBEvent);
+ const BYTE *pSrc = (BYTE*)data.mv_data + sizeof(DBEvent);
if (dbe->flags & DBEF_ENCRYPTED)
{
dbei->flags &= ~DBEF_ENCRYPTED;
size_t len;
- BYTE* pBlob = (BYTE*)m_crypto->decodeBuffer(pSrc, dbe->cbBlob, &len);
- if (pBlob == NULL)
+ mir_ptr<BYTE> pBlob((BYTE*)m_crypto->decodeBuffer(pSrc, dbe->cbBlob, &len));
+ if (pBlob == nullptr)
return 1;
memcpy(dbei->pBlob, pBlob, bytesToCopy);
if (bytesToCopy > len)
memset(dbei->pBlob + len, 0, bytesToCopy - len);
- mir_free(pBlob);
}
else memcpy(dbei->pBlob, pSrc, bytesToCopy);
}
|