From db915e4f76078302d66cff79ed9a3eb63024a261 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 4 Apr 2020 14:31:19 +0300 Subject: code cleaning --- plugins/NewStory/src/history_array.cpp | 48 ++++++++++++++-------------------- 1 file changed, 20 insertions(+), 28 deletions(-) (limited to 'plugins/NewStory/src/history_array.cpp') diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index 86946e6a16..f4138a68a7 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -27,45 +27,39 @@ bool HistoryArray::ItemData::load(EventLoadMode mode) switch (dbe.eventType) { case EVENTTYPE_STATUSCHANGE: case EVENTTYPE_MESSAGE: - { - atext = (char*)dbe.pBlob; + atext = (char *)dbe.pBlob; atext_del = false; - aLength = mir_strlen(atext); + aLength = (int)mir_strlen(atext); if (dbe.cbBlob > (DWORD)aLength + 1) { - wtext = (wchar_t*)(dbe.pBlob + aLength + 1); + wtext = (wchar_t *)(dbe.pBlob + aLength + 1); wtext_del = false; } break; - } case EVENTTYPE_AUTHREQUEST: - { atext = new char[512]; atext_del = true; if ((dbe.cbBlob > 8) && *(dbe.pBlob + 8)) { mir_snprintf(atext, 512, ("%s requested authorization"), dbe.pBlob + 8); } else { - mir_snprintf(atext, 512, ("%d requested authorization"), *(DWORD*)(dbe.pBlob)); + mir_snprintf(atext, 512, ("%d requested authorization"), *(DWORD *)(dbe.pBlob)); } - aLength = mir_strlen(atext); + aLength = (int)mir_strlen(atext); break; - } case EVENTTYPE_ADDED: - { atext = new char[512]; atext_del = true; if ((dbe.cbBlob > 8) && *(dbe.pBlob + 8)) { mir_snprintf(atext, 512, ("%s added you to the contact list"), dbe.pBlob + 8); } else { - mir_snprintf(atext, 512, ("%d added you to the contact list"), *(DWORD*)(dbe.pBlob)); + mir_snprintf(atext, 512, ("%d added you to the contact list"), *(DWORD *)(dbe.pBlob)); } - aLength = mir_strlen(atext); + aLength = (int)mir_strlen(atext); break; } - } if (atext && !wtext) { #ifdef UNICODE @@ -78,17 +72,15 @@ bool HistoryArray::ItemData::load(EventLoadMode mode) wtext_del = false; #endif } - else - if (!atext && wtext) { - // strange situation, really :) I'll fix this later - } - else - if (!atext && !wtext) { - atext = ""; - atext_del = false; - wtext = L""; - wtext_del = false; - } + else if (!atext && wtext) { + // strange situation, really :) I'll fix this later + } + else if (!atext && !wtext) { + atext = ""; + atext_del = false; + wtext = L""; + wtext_del = false; + } return true; } @@ -119,7 +111,7 @@ HistoryArray::~HistoryArray() bool HistoryArray::allocateBlock(int count) { - ItemBlock* newBlock = new ItemBlock; + ItemBlock *newBlock = new ItemBlock; newBlock->items = new ItemData[count]; newBlock->count = count; newBlock->prev = tail; @@ -139,7 +131,7 @@ bool HistoryArray::allocateBlock(int count) void HistoryArray::clear() { while (head) { - ItemBlock* next = head->next; + ItemBlock *next = head->next; // for (int i = 0; i < head->count; ++i) // destroyEvent(head->items[i]); delete[] head->items; @@ -195,10 +187,10 @@ bool HistoryArray::preloadEvents(int count) return true; } */ -HistoryArray::ItemData* HistoryArray::get(int id, EventLoadMode mode) +HistoryArray::ItemData *HistoryArray::get(int id, EventLoadMode mode) { int offset = 0; - for (ItemBlock* p = head; p; p = p->next) { + for (ItemBlock *p = head; p; p = p->next) { if (id < offset + p->count) { if (mode != ELM_NOTHING) p->items[id - offset].load(mode); -- cgit v1.2.3