Bitmap.c: Cleanup some memory management

git-svn-id: svn://vcs.sdm.2ki.xyz/Grabby/trunk@12 27729192-006e-004d-b9b5-06fbd0ef7001
This commit is contained in:
snow flurry 2024-02-15 05:51:35 +00:00
parent d64803c1a9
commit 7d1c91401f

View file

@ -36,6 +36,9 @@ void
DeleteScreen(Screen *scrn)
{
if (scrn) {
if (scrn->hOldObj) SelectObject(scrn->hdcBitmap, scrn->hOldObj);
if (scrn->hBitmap) DeleteObject(scrn->hBitmap);
if (scrn->hScreenRgn) DeleteObject((HGDIOBJ) scrn->hScreenRgn);
if (scrn->hdcBitmap) DeleteDC(scrn->hdcBitmap);
if (scrn->hdcScreen) DeleteDC(scrn->hdcScreen);
@ -57,9 +60,12 @@ PFULLBMPHDR
GenerateBitmapInfo(Screen *scrn,
BITMAP *bmp)
{
// GDI seems to modify the DWORD after the info header, even if we
// don't need a palette (>8 bit BMPs). Thus, an extra RGBQUAD just
// to be safe.
PFULLBMPHDR pBmpHdr = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(struct _FULLBMPHDR));
sizeof(struct _FULLBMPHDR) + sizeof(RGBQUAD));
RECT rcScrn = {0};
WORD cClrBits = (WORD)(bmp->bmPlanes * bmp->bmBitsPixel);
DWORD hdrSize;
@ -337,10 +343,8 @@ cleanup:
if (pHdr) HeapFree(GetProcessHeap(), 0, pHdr);
if (scrn->hOldObj) SelectObject(scrn->hdcBitmap, scrn->hOldObj);
if (hOldObj) SelectObject(hdcRgn, hOldObj);
if (hRgnBitmap) DeleteObject(hRgnBitmap);
if (scrn->hBitmap) DeleteObject(scrn->hBitmap);
if (hdcRgn) DeleteDC(hdcRgn);