Commit b9468c63 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

oleaut32: Use CRT allocation functions in olepicture.c.

parent b07c46fb
...@@ -276,7 +276,7 @@ static HRESULT OLEPictureImpl_Construct(LPPICTDESC pictDesc, BOOL fOwn, OLEPictu ...@@ -276,7 +276,7 @@ static HRESULT OLEPictureImpl_Construct(LPPICTDESC pictDesc, BOOL fOwn, OLEPictu
/* /*
* Allocate space for the object. * Allocate space for the object.
*/ */
newObject = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(OLEPictureImpl)); newObject = calloc(1, sizeof(OLEPictureImpl));
if (!newObject) if (!newObject)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -293,7 +293,7 @@ static HRESULT OLEPictureImpl_Construct(LPPICTDESC pictDesc, BOOL fOwn, OLEPictu ...@@ -293,7 +293,7 @@ static HRESULT OLEPictureImpl_Construct(LPPICTDESC pictDesc, BOOL fOwn, OLEPictu
&newObject->pCP); &newObject->pCP);
if (hr != S_OK) if (hr != S_OK)
{ {
HeapFree(GetProcessHeap(), 0, newObject); free(newObject);
return hr; return hr;
} }
...@@ -395,8 +395,8 @@ static void OLEPictureImpl_Destroy(OLEPictureImpl* Obj) ...@@ -395,8 +395,8 @@ static void OLEPictureImpl_Destroy(OLEPictureImpl* Obj)
break; break;
} }
} }
HeapFree(GetProcessHeap(), 0, Obj->data); free(Obj->data);
HeapFree(GetProcessHeap(), 0, Obj); free(Obj);
} }
static ULONG WINAPI OLEPictureImpl_AddRef( static ULONG WINAPI OLEPictureImpl_AddRef(
...@@ -1042,7 +1042,7 @@ static HRESULT OLEPictureImpl_LoadWICSource(OLEPictureImpl *This, IWICBitmapSour ...@@ -1042,7 +1042,7 @@ static HRESULT OLEPictureImpl_LoadWICSource(OLEPictureImpl *This, IWICBitmapSour
stride = 4 * width; stride = 4 * width;
buffersize = stride * height; buffersize = stride * height;
bits = HeapAlloc(GetProcessHeap(), 0, buffersize); bits = malloc(buffersize);
if (!bits) if (!bits)
{ {
hr = E_OUTOFMEMORY; hr = E_OUTOFMEMORY;
...@@ -1129,7 +1129,7 @@ static HRESULT OLEPictureImpl_LoadWICSource(OLEPictureImpl *This, IWICBitmapSour ...@@ -1129,7 +1129,7 @@ static HRESULT OLEPictureImpl_LoadWICSource(OLEPictureImpl *This, IWICBitmapSour
ReleaseDC(0, hdcref); ReleaseDC(0, hdcref);
end: end:
HeapFree(GetProcessHeap(), 0, bits); free(bits);
IWICBitmapSource_Release(real_source); IWICBitmapSource_Release(real_source);
return hr; return hr;
} }
...@@ -1240,7 +1240,7 @@ static HRESULT OLEPictureImpl_LoadIcon(OLEPictureImpl *This, BYTE *xbuf, ULONG x ...@@ -1240,7 +1240,7 @@ static HRESULT OLEPictureImpl_LoadIcon(OLEPictureImpl *This, BYTE *xbuf, ULONG x
} }
if (cifd->idType == 2) 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, &cifd->idEntries[i].xHotspot, 4);
memcpy(buf + 4, xbuf+cifd->idEntries[i].dwDIBOffset, cifd->idEntries[i].dwDIBSize); memcpy(buf + 4, xbuf+cifd->idEntries[i].dwDIBOffset, cifd->idEntries[i].dwDIBSize);
hicon = CreateIconFromResourceEx( hicon = CreateIconFromResourceEx(
...@@ -1252,7 +1252,7 @@ static HRESULT OLEPictureImpl_LoadIcon(OLEPictureImpl *This, BYTE *xbuf, ULONG x ...@@ -1252,7 +1252,7 @@ static HRESULT OLEPictureImpl_LoadIcon(OLEPictureImpl *This, BYTE *xbuf, ULONG x
cifd->idEntries[i].bHeight, cifd->idEntries[i].bHeight,
0 0
); );
HeapFree(GetProcessHeap(), 0, buf); free(buf);
} }
else else
{ {
...@@ -1430,7 +1430,7 @@ static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream* iface, IStream *pStm) ...@@ -1430,7 +1430,7 @@ static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream* iface, IStream *pStm)
ULONG nread = 42; ULONG nread = 42;
TRACE("Reading all data from stream.\n"); TRACE("Reading all data from stream.\n");
xbuf = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, origsize); xbuf = calloc(1, origsize);
if (headerisdata) if (headerisdata)
memcpy (xbuf, header, 8); memcpy (xbuf, header, 8);
while (1) { while (1) {
...@@ -1443,9 +1443,10 @@ static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream* iface, IStream *pStm) ...@@ -1443,9 +1443,10 @@ static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream* iface, IStream *pStm)
if (!nread || hr != S_OK) /* done, or error */ if (!nread || hr != S_OK) /* done, or error */
break; break;
if (xread == origsize) { if (xread == origsize) {
origsize += sizeinc;
sizeinc = 2*sizeinc; /* exponential increase */ sizeinc = 2*sizeinc; /* exponential increase */
xbuf = HeapReAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, xbuf, origsize); xbuf = realloc(xbuf, origsize + sizeinc);
memset(xbuf + origsize, 0, sizeinc);
origsize += sizeinc;
} }
} }
if (hr != S_OK) if (hr != S_OK)
...@@ -1455,7 +1456,7 @@ static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream* iface, IStream *pStm) ...@@ -1455,7 +1456,7 @@ static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream* iface, IStream *pStm)
This->data = xbuf; This->data = xbuf;
} else { } else {
This->datalen = toread+(headerisdata?8:0); 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) if (!xbuf)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -1542,8 +1543,7 @@ static BOOL serializeBMP(HBITMAP hBitmap, void ** ppBuffer, unsigned int * pLeng ...@@ -1542,8 +1543,7 @@ static BOOL serializeBMP(HBITMAP hBitmap, void ** ppBuffer, unsigned int * pLeng
BITMAPFILEHEADER * pFileHeader; BITMAPFILEHEADER * pFileHeader;
BITMAPINFO * pInfoHeader; BITMAPINFO * pInfoHeader;
pInfoBitmap = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, pInfoBitmap = calloc(1, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
/* Find out bitmap size and padded length */ /* Find out bitmap size and padded length */
hDC = GetDC(0); hDC = GetDC(0);
...@@ -1552,7 +1552,7 @@ static BOOL serializeBMP(HBITMAP hBitmap, void ** ppBuffer, unsigned int * pLeng ...@@ -1552,7 +1552,7 @@ static BOOL serializeBMP(HBITMAP hBitmap, void ** ppBuffer, unsigned int * pLeng
/* Fetch bitmap palette & pixel data */ /* 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); GetDIBits(hDC, hBitmap, 0, pInfoBitmap->bmiHeader.biHeight, pPixelData, pInfoBitmap, DIB_RGB_COLORS);
/* Calculate the total length required for the BMP data */ /* Calculate the total length required for the BMP data */
...@@ -1570,7 +1570,7 @@ static BOOL serializeBMP(HBITMAP hBitmap, void ** ppBuffer, unsigned int * pLeng ...@@ -1570,7 +1570,7 @@ static BOOL serializeBMP(HBITMAP hBitmap, void ** ppBuffer, unsigned int * pLeng
sizeof(BITMAPINFOHEADER) + sizeof(BITMAPINFOHEADER) +
iNumPaletteEntries * sizeof(RGBQUAD) + iNumPaletteEntries * sizeof(RGBQUAD) +
pInfoBitmap->bmiHeader.biSizeImage; pInfoBitmap->bmiHeader.biSizeImage;
*ppBuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, *pLength); *ppBuffer = calloc(1, *pLength);
/* Fill the BITMAPFILEHEADER */ /* Fill the BITMAPFILEHEADER */
pFileHeader = *ppBuffer; pFileHeader = *ppBuffer;
...@@ -1592,8 +1592,8 @@ static BOOL serializeBMP(HBITMAP hBitmap, void ** ppBuffer, unsigned int * pLeng ...@@ -1592,8 +1592,8 @@ static BOOL serializeBMP(HBITMAP hBitmap, void ** ppBuffer, unsigned int * pLeng
pPixelData, pInfoBitmap->bmiHeader.biSizeImage); pPixelData, pInfoBitmap->bmiHeader.biSizeImage);
success = TRUE; success = TRUE;
HeapFree(GetProcessHeap(), 0, pPixelData); free(pPixelData);
HeapFree(GetProcessHeap(), 0, pInfoBitmap); free(pInfoBitmap);
return success; return success;
} }
...@@ -1609,7 +1609,7 @@ static BOOL serializeIcon(HICON hIcon, void ** ppBuffer, unsigned int * pLength) ...@@ -1609,7 +1609,7 @@ static BOOL serializeIcon(HICON hIcon, void ** ppBuffer, unsigned int * pLength)
unsigned char * pIconData = NULL; unsigned char * pIconData = NULL;
unsigned int iDataSize = 0; 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 */ /* Find out icon size */
hDC = GetDC(0); hDC = GetDC(0);
...@@ -1641,7 +1641,7 @@ static BOOL serializeIcon(HICON hIcon, void ** ppBuffer, unsigned int * pLength) ...@@ -1641,7 +1641,7 @@ static BOOL serializeIcon(HICON hIcon, void ** ppBuffer, unsigned int * pLength)
*/ */
/* Let's start with one CURSORICONFILEDIR and one CURSORICONFILEDIRENTRY */ /* Let's start with one CURSORICONFILEDIR and one CURSORICONFILEDIRENTRY */
iDataSize += 3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY) + sizeof(BITMAPINFOHEADER); iDataSize += 3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY) + sizeof(BITMAPINFOHEADER);
pIconData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, iDataSize); pIconData = calloc(1, iDataSize);
/* Fill out the CURSORICONFILEDIR */ /* Fill out the CURSORICONFILEDIR */
pIconDir = (CURSORICONFILEDIR *)pIconData; pIconDir = (CURSORICONFILEDIR *)pIconData;
...@@ -1690,7 +1690,7 @@ static BOOL serializeIcon(HICON hIcon, void ** ppBuffer, unsigned int * pLength) ...@@ -1690,7 +1690,7 @@ static BOOL serializeIcon(HICON hIcon, void ** ppBuffer, unsigned int * pLength)
iDataSize += pIconBitmapHeader->biHeight * iLengthScanLineMask; iDataSize += pIconBitmapHeader->biHeight * iLengthScanLineMask;
pIconBitmapHeader->biSizeImage += pIconBitmapHeader->biHeight * iLengthScanLineMask; pIconBitmapHeader->biSizeImage += pIconBitmapHeader->biHeight * iLengthScanLineMask;
pIconBitmapHeader->biHeight *= 2; pIconBitmapHeader->biHeight *= 2;
pIconData = HeapReAlloc(GetProcessHeap(), 0, pIconData, iDataSize); pIconData = realloc(pIconData, iDataSize);
pIconEntry = (CURSORICONFILEDIRENTRY *)(pIconData + 3 * sizeof(WORD)); pIconEntry = (CURSORICONFILEDIRENTRY *)(pIconData + 3 * sizeof(WORD));
pIconBitmapHeader = (BITMAPINFOHEADER *)(pIconData + 3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY)); pIconBitmapHeader = (BITMAPINFOHEADER *)(pIconData + 3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY));
pIconEntry->dwDIBSize = iDataSize - (3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY)); pIconEntry->dwDIBSize = iDataSize - (3 * sizeof(WORD) + sizeof(CURSORICONFILEDIRENTRY));
...@@ -1740,7 +1740,7 @@ static BOOL serializeIcon(HICON hIcon, void ** ppBuffer, unsigned int * pLength) ...@@ -1740,7 +1740,7 @@ static BOOL serializeIcon(HICON hIcon, void ** ppBuffer, unsigned int * pLength)
if (hDC) ReleaseDC(0, hDC); if (hDC) ReleaseDC(0, hDC);
DeleteObject(infoIcon.hbmMask); DeleteObject(infoIcon.hbmMask);
if (infoIcon.hbmColor) DeleteObject(infoIcon.hbmColor); if (infoIcon.hbmColor) DeleteObject(infoIcon.hbmColor);
HeapFree(GetProcessHeap(), 0, pInfoBitmap); free(pInfoBitmap);
} else { } else {
ERR("Unable to get icon information (error %lu)\n", GetLastError()); ERR("Unable to get icon information (error %lu)\n", GetLastError());
} }
...@@ -1774,7 +1774,7 @@ static HRESULT WINAPI OLEPictureImpl_Save( ...@@ -1774,7 +1774,7 @@ static HRESULT WINAPI OLEPictureImpl_Save(
hResult = E_FAIL; hResult = E_FAIL;
break; break;
} }
HeapFree(GetProcessHeap(), 0, This->data); free(This->data);
This->data = pIconData; This->data = pIconData;
This->datalen = iDataSize; This->datalen = iDataSize;
} }
...@@ -1811,7 +1811,7 @@ static HRESULT WINAPI OLEPictureImpl_Save( ...@@ -1811,7 +1811,7 @@ static HRESULT WINAPI OLEPictureImpl_Save(
break; break;
} }
HeapFree(GetProcessHeap(), 0, This->data); free(This->data);
This->data = pIconData; This->data = pIconData;
This->datalen = iDataSize; This->datalen = iDataSize;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment