mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-14 18:37:17 +00:00
oleaut32: Use CRT allocation functions in olepicture.c.
This commit is contained in:
parent
b07c46fb0b
commit
b9468c636f
|
@ -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) {
|
||||
|
@ -1443,9 +1443,10 @@ static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream* iface, IStream *pStm)
|
|||
if (!nread || hr != S_OK) /* done, or error */
|
||||
break;
|
||||
if (xread == origsize) {
|
||||
origsize += sizeinc;
|
||||
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)
|
||||
|
@ -1455,7 +1456,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 +1543,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 +1552,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 +1570,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 +1592,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 +1609,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 +1641,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 +1690,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 +1740,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 +1774,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 +1811,7 @@ static HRESULT WINAPI OLEPictureImpl_Save(
|
|||
break;
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, This->data);
|
||||
free(This->data);
|
||||
This->data = pIconData;
|
||||
This->datalen = iDataSize;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue