Avoid excessive heap memory reallocation when generating EMF
metarecords in memory.
This commit is contained in:
parent
c93c27f420
commit
a7bbf47f1b
@ -185,12 +185,16 @@ BOOL EMFDRV_WriteRecord( PHYSDEV dev, EMR *emr )
|
|||||||
if (!WriteFile(physDev->hFile, (char *)emr, emr->nSize, NULL, NULL))
|
if (!WriteFile(physDev->hFile, (char *)emr, emr->nSize, NULL, NULL))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else {
|
} else {
|
||||||
len = physDev->emh->nBytes;
|
DWORD nEmfSize = HeapSize(GetProcessHeap(), 0, physDev->emh);
|
||||||
emh = HeapReAlloc( GetProcessHeap(), 0, physDev->emh, len );
|
len = physDev->emh->nBytes;
|
||||||
if (!emh) return FALSE;
|
if (len > nEmfSize) {
|
||||||
physDev->emh = emh;
|
nEmfSize += (nEmfSize / 2) + emr->nSize;
|
||||||
memcpy((CHAR *)physDev->emh + physDev->emh->nBytes - emr->nSize, emr,
|
emh = HeapReAlloc(GetProcessHeap(), 0, physDev->emh, nEmfSize);
|
||||||
emr->nSize);
|
if (!emh) return FALSE;
|
||||||
|
physDev->emh = emh;
|
||||||
|
}
|
||||||
|
memcpy((CHAR *)physDev->emh + physDev->emh->nBytes - emr->nSize, emr,
|
||||||
|
emr->nSize);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user