Commit a7bbf47f authored by Dave Belanger's avatar Dave Belanger Committed by Alexandre Julliard

Avoid excessive heap memory reallocation when generating EMF

metarecords in memory.
parent c93c27f4
......@@ -185,10 +185,14 @@ BOOL EMFDRV_WriteRecord( PHYSDEV dev, EMR *emr )
if (!WriteFile(physDev->hFile, (char *)emr, emr->nSize, NULL, NULL))
return FALSE;
} else {
DWORD nEmfSize = HeapSize(GetProcessHeap(), 0, physDev->emh);
len = physDev->emh->nBytes;
emh = HeapReAlloc( GetProcessHeap(), 0, physDev->emh, len );
if (len > nEmfSize) {
nEmfSize += (nEmfSize / 2) + emr->nSize;
emh = HeapReAlloc(GetProcessHeap(), 0, physDev->emh, nEmfSize);
if (!emh) return FALSE;
physDev->emh = emh;
}
memcpy((CHAR *)physDev->emh + physDev->emh->nBytes - emr->nSize, emr,
emr->nSize);
}
......
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