diff options
author | George Hazan <ghazan@miranda.im> | 2021-06-05 17:50:34 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2021-06-05 17:50:34 +0300 |
commit | d7c9eb34f80f207efd47d2fc65e31aedf166c323 (patch) | |
tree | 338b9b905674dc31b1efab739dfcedeed3d8d7b3 /protocols/Discord/src | |
parent | ffc5a3d7550528281976745279e77ac9faba551b (diff) |
major code cleaning in regard to db_event_getBlobSize & event memory allocation
Diffstat (limited to 'protocols/Discord/src')
-rw-r--r-- | protocols/Discord/src/dispatch.cpp | 6 | ||||
-rw-r--r-- | protocols/Discord/src/proto.cpp | 10 |
2 files changed, 6 insertions, 10 deletions
diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp index 4f2d25d35d..6cdef5e4de 100644 --- a/protocols/Discord/src/dispatch.cpp +++ b/protocols/Discord/src/dispatch.cpp @@ -390,9 +390,8 @@ void CDiscordProto::OnCommandMessage(const JSONNode &pRoot, bool bIsNew) if (!bIsNew) { MEVENT hOldEvent = db_event_getById(m_szModuleName, szMsgId); if (hOldEvent) { - DBEVENTINFO dbei = {}; - dbei.cbBlob = db_event_getBlobSize(hOldEvent); - dbei.pBlob = (BYTE*)mir_alloc(dbei.cbBlob); + DB::EventInfo dbei; + dbei.cbBlob = -1; if (!db_event_get(hOldEvent, &dbei)) { ptrW wszOldText(DbEvent_GetTextW(&dbei, CP_UTF8)); if (wszOldText) @@ -400,7 +399,6 @@ void CDiscordProto::OnCommandMessage(const JSONNode &pRoot, bool bIsNew) if (dbei.flags & DBEF_SENT) bOurMessage = true; } - mir_free(dbei.pBlob); } } diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp index c8304b6375..e5a62df682 100644 --- a/protocols/Discord/src/proto.cpp +++ b/protocols/Discord/src/proto.cpp @@ -374,9 +374,8 @@ int CDiscordProto::AuthRecv(MCONTACT, PROTORECVEVENT *pre) int CDiscordProto::Authorize(MEVENT hDbEvent) { - DBEVENTINFO dbei = {}; - if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == (DWORD)(-1)) return 1; - if ((dbei.pBlob = (PBYTE)alloca(dbei.cbBlob)) == nullptr) return 1; + DB::EventInfo dbei; + dbei.cbBlob = -1; if (db_event_get(hDbEvent, &dbei)) return 1; if (dbei.eventType != EVENTTYPE_AUTHREQUEST) return 1; if (mir_strcmp(dbei.szModule, m_szModuleName)) return 1; @@ -390,9 +389,8 @@ int CDiscordProto::Authorize(MEVENT hDbEvent) int CDiscordProto::AuthDeny(MEVENT hDbEvent, const wchar_t*) { - DBEVENTINFO dbei = {}; - if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == (DWORD)(-1)) return 1; - if ((dbei.pBlob = (PBYTE)alloca(dbei.cbBlob)) == nullptr) return 1; + DB::EventInfo dbei; + dbei.cbBlob = -1; if (db_event_get(hDbEvent, &dbei)) return 1; if (dbei.eventType != EVENTTYPE_AUTHREQUEST) return 1; if (mir_strcmp(dbei.szModule, m_szModuleName)) return 1; |