Dmitry Timoshkov : gdiplus: Avoid not necessary memory allocation for BITMAPINFO.

Alexandre Julliard julliard at winehq.org
Tue Jan 15 13:46:17 CST 2013


Module: wine
Branch: master
Commit: bd601f9950c9d89e9c205f86e399dc283652392a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=bd601f9950c9d89e9c205f86e399dc283652392a

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Tue Jan 15 12:48:56 2013 +0800

gdiplus: Avoid not necessary memory allocation for BITMAPINFO.

---

 dlls/gdiplus/image.c |   23 ++++++++---------------
 1 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
index 377cab1..b182405 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -4694,28 +4694,21 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
         if (retval == Ok)
         {
             HDC hdc;
-            BITMAPINFO *pbmi;
+            char bmibuf[FIELD_OFFSET(BITMAPINFO, bmiColors[256])];
+            BITMAPINFO *pbmi = (BITMAPINFO *)bmibuf;
             INT src_height;
 
             hdc = CreateCompatibleDC(NULL);
-            pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
 
-            if (pbmi)
-            {
-                pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
-                pbmi->bmiHeader.biBitCount = 0;
-
-                GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS);
+            pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+            pbmi->bmiHeader.biBitCount = 0;
 
-                src_height = abs(pbmi->bmiHeader.biHeight);
-                pbmi->bmiHeader.biHeight = -src_height;
+            GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS);
 
-                GetDIBits(hdc, hbm, 0, src_height, lockeddata.Scan0, pbmi, DIB_RGB_COLORS);
+            src_height = abs(pbmi->bmiHeader.biHeight);
+            pbmi->bmiHeader.biHeight = -src_height;
 
-                GdipFree(pbmi);
-            }
-            else
-                retval = OutOfMemory;
+            GetDIBits(hdc, hbm, 0, src_height, lockeddata.Scan0, pbmi, DIB_RGB_COLORS);
 
             DeleteDC(hdc);
 




More information about the wine-cvs mailing list