From: Alex Henrie alexhenrie24@gmail.com
--- dlls/oleaut32/olepicture.c | 45 +++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 23 deletions(-)
diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c index b11493d5739..8a91b69a84b 100644 --- a/dlls/oleaut32/olepicture.c +++ b/dlls/oleaut32/olepicture.c @@ -276,7 +276,7 @@ static HRESULT OLEPictureImpl_Construct(LPPICTDESC pictDesc, BOOL fOwn, OLEPictu /* * Allocate space for the object. */ - newObject = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(OLEPictureImpl)); + newObject = calloc(1, sizeof(OLEPictureImpl)); if (!newObject) return E_OUTOFMEMORY;
@@ -293,7 +293,7 @@ static HRESULT OLEPictureImpl_Construct(LPPICTDESC pictDesc, BOOL fOwn, OLEPictu &newObject->pCP); if (hr != S_OK) { - HeapFree(GetProcessHeap(), 0, newObject); + free(newObject); return hr; }
@@ -395,8 +395,8 @@ static void OLEPictureImpl_Destroy(OLEPictureImpl* Obj) break; } } - HeapFree(GetProcessHeap(), 0, Obj->data); - HeapFree(GetProcessHeap(), 0, Obj); + free(Obj->data); + free(Obj); }
static ULONG WINAPI OLEPictureImpl_AddRef( @@ -1042,7 +1042,7 @@ static HRESULT OLEPictureImpl_LoadWICSource(OLEPictureImpl *This, IWICBitmapSour stride = 4 * width; buffersize = stride * height;
- bits = HeapAlloc(GetProcessHeap(), 0, buffersize); + bits = malloc(buffersize); if (!bits) { hr = E_OUTOFMEMORY; @@ -1129,7 +1129,7 @@ static HRESULT OLEPictureImpl_LoadWICSource(OLEPictureImpl *This, IWICBitmapSour ReleaseDC(0, hdcref);
end: - HeapFree(GetProcessHeap(), 0, bits); + free(bits); IWICBitmapSource_Release(real_source); return hr; } @@ -1240,7 +1240,7 @@ static HRESULT OLEPictureImpl_LoadIcon(OLEPictureImpl *This, BYTE *xbuf, ULONG x } if (cifd->idType == 2) { - LPBYTE buf = HeapAlloc(GetProcessHeap(), 0, cifd->idEntries[i].dwDIBSize + 4); + BYTE *buf = malloc(cifd->idEntries[i].dwDIBSize + 4); memcpy(buf, &cifd->idEntries[i].xHotspot, 4); memcpy(buf + 4, xbuf+cifd->idEntries[i].dwDIBOffset, cifd->idEntries[i].dwDIBSize); hicon = CreateIconFromResourceEx( @@ -1252,7 +1252,7 @@ static HRESULT OLEPictureImpl_LoadIcon(OLEPictureImpl *This, BYTE *xbuf, ULONG x cifd->idEntries[i].bHeight, 0 ); - HeapFree(GetProcessHeap(), 0, buf); + free(buf); } else { @@ -1430,7 +1430,7 @@ static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream* iface, IStream *pStm) ULONG nread = 42;
TRACE("Reading all data from stream.\n"); - xbuf = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, origsize); + xbuf = calloc(1, origsize); if (headerisdata) memcpy (xbuf, header, 8); while (1) { @@ -1445,7 +1445,7 @@ static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream* iface, IStream *pStm) if (xread == origsize) { origsize += sizeinc; sizeinc = 2*sizeinc; /* exponential increase */ - xbuf = HeapReAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, xbuf, origsize); + xbuf = _recalloc(xbuf, 1, origsize); } } if (hr != S_OK) @@ -1455,7 +1455,7 @@ static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream* iface, IStream *pStm) This->data = xbuf; } else { This->datalen = toread+(headerisdata?8:0); - xbuf = This->data = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, This->datalen); + xbuf = This->data = calloc(1, This->datalen); if (!xbuf) return E_OUTOFMEMORY;
@@ -1542,8 +1542,7 @@ static BOOL serializeBMP(HBITMAP hBitmap, void ** ppBuffer, unsigned int * pLeng BITMAPFILEHEADER * pFileHeader; BITMAPINFO * pInfoHeader;
- pInfoBitmap = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); + pInfoBitmap = calloc(1, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
/* Find out bitmap size and padded length */ hDC = GetDC(0); @@ -1552,7 +1551,7 @@ static BOOL serializeBMP(HBITMAP hBitmap, void ** ppBuffer, unsigned int * pLeng
/* Fetch bitmap palette & pixel data */
- pPixelData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, pInfoBitmap->bmiHeader.biSizeImage); + pPixelData = calloc(1, pInfoBitmap->bmiHeader.biSizeImage); GetDIBits(hDC, hBitmap, 0, pInfoBitmap->bmiHeader.biHeight, pPixelData, pInfoBitmap, DIB_RGB_COLORS);
/* Calculate the total length required for the BMP data */ @@ -1570,7 +1569,7 @@ static BOOL serializeBMP(HBITMAP hBitmap, void ** ppBuffer, unsigned int * pLeng sizeof(BITMAPINFOHEADER) + iNumPaletteEntries * sizeof(RGBQUAD) + pInfoBitmap->bmiHeader.biSizeImage; - *ppBuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, *pLength); + *ppBuffer = calloc(1, *pLength);
/* Fill the BITMAPFILEHEADER */ pFileHeader = *ppBuffer; @@ -1592,8 +1591,8 @@ static BOOL serializeBMP(HBITMAP hBitmap, void ** ppBuffer, unsigned int * pLeng pPixelData, pInfoBitmap->bmiHeader.biSizeImage); success = TRUE;
- HeapFree(GetProcessHeap(), 0, pPixelData); - HeapFree(GetProcessHeap(), 0, pInfoBitmap); + free(pPixelData); + free(pInfoBitmap); return success; }
@@ -1609,7 +1608,7 @@ static BOOL serializeIcon(HICON hIcon, void ** ppBuffer, unsigned int * pLength) unsigned char * pIconData = NULL; unsigned int iDataSize = 0;
- pInfoBitmap = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); + pInfoBitmap = calloc(1, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
/* Find out icon size */ hDC = GetDC(0); @@ -1641,7 +1640,7 @@ static BOOL serializeIcon(HICON hIcon, void ** ppBuffer, unsigned int * pLength) */ /* Let's start with one CURSORICONFILEDIR and one CURSORICONFILEDIRENTRY */ iDataSize += 3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY) + sizeof(BITMAPINFOHEADER); - pIconData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, iDataSize); + pIconData = calloc(1, iDataSize);
/* Fill out the CURSORICONFILEDIR */ pIconDir = (CURSORICONFILEDIR *)pIconData; @@ -1690,7 +1689,7 @@ static BOOL serializeIcon(HICON hIcon, void ** ppBuffer, unsigned int * pLength) iDataSize += pIconBitmapHeader->biHeight * iLengthScanLineMask; pIconBitmapHeader->biSizeImage += pIconBitmapHeader->biHeight * iLengthScanLineMask; pIconBitmapHeader->biHeight *= 2; - pIconData = HeapReAlloc(GetProcessHeap(), 0, pIconData, iDataSize); + pIconData = realloc(pIconData, iDataSize); pIconEntry = (CURSORICONFILEDIRENTRY *)(pIconData + 3 * sizeof(WORD)); pIconBitmapHeader = (BITMAPINFOHEADER *)(pIconData + 3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY)); pIconEntry->dwDIBSize = iDataSize - (3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY)); @@ -1740,7 +1739,7 @@ static BOOL serializeIcon(HICON hIcon, void ** ppBuffer, unsigned int * pLength) if (hDC) ReleaseDC(0, hDC); DeleteObject(infoIcon.hbmMask); if (infoIcon.hbmColor) DeleteObject(infoIcon.hbmColor); - HeapFree(GetProcessHeap(), 0, pInfoBitmap); + free(pInfoBitmap); } else { ERR("Unable to get icon information (error %lu)\n", GetLastError()); } @@ -1774,7 +1773,7 @@ static HRESULT WINAPI OLEPictureImpl_Save( hResult = E_FAIL; break; } - HeapFree(GetProcessHeap(), 0, This->data); + free(This->data); This->data = pIconData; This->datalen = iDataSize; } @@ -1811,7 +1810,7 @@ static HRESULT WINAPI OLEPictureImpl_Save( break; }
- HeapFree(GetProcessHeap(), 0, This->data); + free(This->data); This->data = pIconData; This->datalen = iDataSize; }