From 35fc9c12dcffa646dfb56c6a48930f5b6a6e208c Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Wed, 30 Jan 2013 18:02:14 +0800 Subject: [PATCH] gdiplus: Avoid not necessary memory allocation for BITMAPINFO. --- dlls/gdiplus/image.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index 6aa8d326cf2..9c3433309a5 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -1821,7 +1821,6 @@ static GpStatus get_screen_resolution(REAL *xres, REAL *yres) GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, PixelFormat format, BYTE* scan0, GpBitmap** bitmap) { - BITMAPINFO* pbmi; HBITMAP hbitmap=NULL; INT row_size, dib_stride; BYTE *bits=NULL, *own_bits=NULL; @@ -1851,9 +1850,8 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, if (format & PixelFormatGDI && !(format & (PixelFormatAlpha|PixelFormatIndexed)) && !scan0) { - pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); - if (!pbmi) - return OutOfMemory; + char bmibuf[FIELD_OFFSET(BITMAPINFO, bmiColors[256])]; + BITMAPINFO *pbmi = (BITMAPINFO *)bmibuf; pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); pbmi->bmiHeader.biWidth = width; @@ -1870,8 +1868,6 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, hbitmap = CreateDIBSection(0, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0); - GdipFree(pbmi); - if (!hbitmap) return GenericError; stride = dib_stride;