From 965ba4945c4efe30614e756c2c7b5ec102cf7c41 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 26 Apr 2013 21:45:16 +0000 Subject: code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@4545 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/sendqueue.cpp | 37 ++++++++++++------------------------- plugins/TabSRMM/src/sendqueue.h | 1 - plugins/TabSRMM/src/themes.cpp | 26 ++++++++++---------------- 3 files changed, 22 insertions(+), 42 deletions(-) (limited to 'plugins') diff --git a/plugins/TabSRMM/src/sendqueue.cpp b/plugins/TabSRMM/src/sendqueue.cpp index 03732b2b1b..73c3e505e3 100644 --- a/plugins/TabSRMM/src/sendqueue.cpp +++ b/plugins/TabSRMM/src/sendqueue.cpp @@ -73,7 +73,7 @@ void SendQueue::handleError(TWindowData *dat, const int iEntry) const */ int SendQueue::addTo(TWindowData *dat, const int iLen, int dwFlags) { - int iLength = 0, i; + int i; int iFound = NR_SENDJOBS; if (m_currentIndex >= NR_SENDJOBS) { @@ -104,20 +104,15 @@ entry_found: } SendJob &job = m_jobs[iFound]; - iLength = iLen; + int iLength = iLen; if (iLength > 0) { if (job.szSendBuffer == NULL) { if (iLength < HISTORY_INITIAL_ALLOCSIZE) iLength = HISTORY_INITIAL_ALLOCSIZE; job.szSendBuffer = (char*)mir_alloc(iLength); - job.dwLen = iLength; - } - else { - if (iLength > job.dwLen) { - job.szSendBuffer = (char*)mir_realloc(job.szSendBuffer, iLength); - job.dwLen = iLength; - } } + else job.szSendBuffer = (char*)mir_realloc(job.szSendBuffer, iLength); + CopyMemory(job.szSendBuffer, dat->sendBuffer, iLen); } job.dwFlags = dwFlags; @@ -459,15 +454,9 @@ send_unsplitted: void SendQueue::clearJob(const int iIndex) { - m_jobs[iIndex].hOwner = 0; - m_jobs[iIndex].hwndOwner = 0; - m_jobs[iIndex].iStatus = 0; - m_jobs[iIndex].iAcksNeeded = 0; - m_jobs[iIndex].dwFlags = 0; - m_jobs[iIndex].chunkSize = 0; - m_jobs[iIndex].dwTime = 0; - m_jobs[iIndex].hSendId = 0; - m_jobs[iIndex].iSendLength = 0; + SendJob &job = m_jobs[iIndex]; + mir_free(job.szSendBuffer); + memset(&job, 0, sizeof(SendJob)); } /* @@ -718,8 +707,7 @@ int SendQueue::ackMessage(TWindowData *dat, WPARAM wParam, LPARAM lParam) SkinPlaySound("SendError"); TCHAR *szAckMsg = mir_a2t((char *)ack->lParam); - mir_sntprintf(job.szErrorMsg, SIZEOF(job.szErrorMsg), - TranslateT("Delivery failure: %s"), szAckMsg); + mir_sntprintf(job.szErrorMsg, SIZEOF(job.szErrorMsg), TranslateT("Delivery failure: %s"), szAckMsg); job.iStatus = SQ_ERROR; mir_free(szAckMsg); KillTimer(dat->hwnd, TIMERID_MSGSEND + iFound); @@ -727,12 +715,11 @@ int SendQueue::ackMessage(TWindowData *dat, WPARAM wParam, LPARAM lParam) handleError(dat, iFound); return 0; } - else { + inform_and_discard: - _DebugPopup(job.hOwner, TranslateT("A message delivery has failed after the contacts chat window was closed. You may want to resend the last message")); - clearJob(iFound); - return 0; - } + _DebugPopup(job.hOwner, TranslateT("A message delivery has failed after the contacts chat window was closed. You may want to resend the last message")); + clearJob(iFound); + return 0; } DBEVENTINFO dbei = { sizeof(dbei) }; diff --git a/plugins/TabSRMM/src/sendqueue.h b/plugins/TabSRMM/src/sendqueue.h index a5b2e63d69..fa23a189d9 100644 --- a/plugins/TabSRMM/src/sendqueue.h +++ b/plugins/TabSRMM/src/sendqueue.h @@ -42,7 +42,6 @@ struct SendJob { HANDLE hSendId; char *szSendBuffer; - int dwLen; // actual buffer length (checked for reallocs() int iSendLength; // length of message in utf-8 octets (used to check maxlen) int sendCount; HANDLE hOwner; diff --git a/plugins/TabSRMM/src/themes.cpp b/plugins/TabSRMM/src/themes.cpp index 56defcc5ff..4e439fff18 100644 --- a/plugins/TabSRMM/src/themes.cpp +++ b/plugins/TabSRMM/src/themes.cpp @@ -928,8 +928,6 @@ void CImageItem::Free() void CImageItem::SetBitmap32Alpha(HBITMAP hBitmap, BYTE bAlpha) { BITMAP bmp; - DWORD dwLen; - BYTE *p; int x, y; BOOL fixIt = TRUE; @@ -938,8 +936,8 @@ void CImageItem::SetBitmap32Alpha(HBITMAP hBitmap, BYTE bAlpha) if (bmp.bmBitsPixel != 32) return; - dwLen = bmp.bmWidth * bmp.bmHeight * (bmp.bmBitsPixel / 8); - p = (BYTE *)malloc(dwLen); + DWORD dwLen = bmp.bmWidth * bmp.bmHeight * (bmp.bmBitsPixel / 8); + BYTE *p = (BYTE *)malloc(dwLen); if (p == NULL) return; memset(p, 0, dwLen); @@ -960,25 +958,21 @@ void CImageItem::SetBitmap32Alpha(HBITMAP hBitmap, BYTE bAlpha) void CImageItem::PreMultiply(HBITMAP hBitmap, int mode) { - BYTE *p = NULL; - DWORD dwLen; - int width, height, x, y; BITMAP bmp; - BYTE alpha; - ::GetObject(hBitmap, sizeof(bmp), &bmp); - width = bmp.bmWidth; - height = bmp.bmHeight; - dwLen = width * height * 4; - p = (BYTE *)malloc(dwLen); + + int width = bmp.bmWidth; + int height = bmp.bmHeight; + DWORD dwLen = width * height * 4; + BYTE *p = (BYTE *)malloc(dwLen); if (p) { ::GetBitmapBits(hBitmap, dwLen, p); - for (y = 0; y < height; ++y) { + for (int y = 0; y < height; ++y) { BYTE *px = p + width * 4 * y; - for (x = 0; x < width; ++x) { + for (int x = 0; x < width; ++x) { if (mode) { - alpha = px[3]; + BYTE alpha = px[3]; px[0] = px[0] * alpha / 255; px[1] = px[1] * alpha / 255; px[2] = px[2] * alpha / 255; -- cgit v1.2.3