wineps: Move some allocations to the process heap.
This commit is contained in:
parent
e370f4bf3a
commit
e31cfb0be1
|
@ -221,7 +221,7 @@ DWORD PSDRV_WriteSpool(PHYSDEV dev, LPCSTR lpData, DWORD cch)
|
||||||
static INT PSDRV_WriteFeature(PHYSDEV dev, LPCSTR feature, LPCSTR value, LPCSTR invocation)
|
static INT PSDRV_WriteFeature(PHYSDEV dev, LPCSTR feature, LPCSTR value, LPCSTR invocation)
|
||||||
{
|
{
|
||||||
|
|
||||||
char *buf = HeapAlloc( PSDRV_Heap, 0, sizeof(psbeginfeature) +
|
char *buf = HeapAlloc( GetProcessHeap(), 0, sizeof(psbeginfeature) +
|
||||||
strlen(feature) + strlen(value));
|
strlen(feature) + strlen(value));
|
||||||
|
|
||||||
sprintf(buf, psbeginfeature, feature, value);
|
sprintf(buf, psbeginfeature, feature, value);
|
||||||
|
@ -229,7 +229,7 @@ static INT PSDRV_WriteFeature(PHYSDEV dev, LPCSTR feature, LPCSTR value, LPCSTR
|
||||||
write_spool( dev, invocation, strlen(invocation) );
|
write_spool( dev, invocation, strlen(invocation) );
|
||||||
write_spool( dev, psendfeature, strlen(psendfeature) );
|
write_spool( dev, psendfeature, strlen(psendfeature) );
|
||||||
|
|
||||||
HeapFree( PSDRV_Heap, 0, buf );
|
HeapFree( GetProcessHeap(), 0, buf );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,11 +306,12 @@ INT PSDRV_WriteHeader( PHYSDEV dev, LPCWSTR title )
|
||||||
DUPLEX *duplex;
|
DUPLEX *duplex;
|
||||||
int win_duplex;
|
int win_duplex;
|
||||||
int llx, lly, urx, ury;
|
int llx, lly, urx, ury;
|
||||||
|
int ret, len;
|
||||||
|
|
||||||
TRACE("%s\n", debugstr_w(title));
|
TRACE("%s\n", debugstr_w(title));
|
||||||
|
|
||||||
escaped_title = escape_title(title);
|
escaped_title = escape_title(title);
|
||||||
buf = HeapAlloc( PSDRV_Heap, 0, sizeof(psheader) +
|
buf = HeapAlloc( GetProcessHeap(), 0, sizeof(psheader) +
|
||||||
strlen(escaped_title) + 30 );
|
strlen(escaped_title) + 30 );
|
||||||
if(!buf) {
|
if(!buf) {
|
||||||
WARN("HeapAlloc failed\n");
|
WARN("HeapAlloc failed\n");
|
||||||
|
@ -328,12 +329,15 @@ INT PSDRV_WriteHeader( PHYSDEV dev, LPCWSTR title )
|
||||||
sprintf(buf, psheader, escaped_title, llx, lly, urx, ury);
|
sprintf(buf, psheader, escaped_title, llx, lly, urx, ury);
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, escaped_title);
|
HeapFree(GetProcessHeap(), 0, escaped_title);
|
||||||
if( write_spool( dev, buf, strlen(buf) ) != strlen(buf) ) {
|
|
||||||
|
len = strlen( buf );
|
||||||
|
ret = write_spool( dev, buf, len );
|
||||||
|
HeapFree( GetProcessHeap(), 0, buf );
|
||||||
|
if (ret != len)
|
||||||
|
{
|
||||||
WARN("WriteSpool error\n");
|
WARN("WriteSpool error\n");
|
||||||
HeapFree( PSDRV_Heap, 0, buf );
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
HeapFree( PSDRV_Heap, 0, buf );
|
|
||||||
|
|
||||||
write_spool( dev, psbeginprolog, strlen(psbeginprolog) );
|
write_spool( dev, psbeginprolog, strlen(psbeginprolog) );
|
||||||
write_spool( dev, psprolog, strlen(psprolog) );
|
write_spool( dev, psprolog, strlen(psprolog) );
|
||||||
|
@ -389,8 +393,9 @@ INT PSDRV_WriteFooter( PHYSDEV dev )
|
||||||
{
|
{
|
||||||
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
|
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
|
||||||
char *buf;
|
char *buf;
|
||||||
|
int ret = 1;
|
||||||
|
|
||||||
buf = HeapAlloc( PSDRV_Heap, 0, sizeof(psfooter) + 100 );
|
buf = HeapAlloc( GetProcessHeap(), 0, sizeof(psfooter) + 100 );
|
||||||
if(!buf) {
|
if(!buf) {
|
||||||
WARN("HeapAlloc failed\n");
|
WARN("HeapAlloc failed\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -400,11 +405,10 @@ INT PSDRV_WriteFooter( PHYSDEV dev )
|
||||||
|
|
||||||
if( write_spool( dev, buf, strlen(buf) ) != strlen(buf) ) {
|
if( write_spool( dev, buf, strlen(buf) ) != strlen(buf) ) {
|
||||||
WARN("WriteSpool error\n");
|
WARN("WriteSpool error\n");
|
||||||
HeapFree( PSDRV_Heap, 0, buf );
|
ret = 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
HeapFree( PSDRV_Heap, 0, buf );
|
HeapFree( GetProcessHeap(), 0, buf );
|
||||||
return 1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -427,10 +431,11 @@ INT PSDRV_WriteNewPage( PHYSDEV dev )
|
||||||
char *buf;
|
char *buf;
|
||||||
char name[100];
|
char name[100];
|
||||||
signed int xtrans, ytrans, rotation;
|
signed int xtrans, ytrans, rotation;
|
||||||
|
int ret = 1;
|
||||||
|
|
||||||
sprintf(name, "%d", physDev->job.PageNo);
|
sprintf(name, "%d", physDev->job.PageNo);
|
||||||
|
|
||||||
buf = HeapAlloc( PSDRV_Heap, 0, sizeof(psnewpage) + 200 );
|
buf = HeapAlloc( GetProcessHeap(), 0, sizeof(psnewpage) + 200 );
|
||||||
if(!buf) {
|
if(!buf) {
|
||||||
WARN("HeapAlloc failed\n");
|
WARN("HeapAlloc failed\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -458,11 +463,10 @@ INT PSDRV_WriteNewPage( PHYSDEV dev )
|
||||||
|
|
||||||
if( write_spool( dev, buf, strlen(buf) ) != strlen(buf) ) {
|
if( write_spool( dev, buf, strlen(buf) ) != strlen(buf) ) {
|
||||||
WARN("WriteSpool error\n");
|
WARN("WriteSpool error\n");
|
||||||
HeapFree( PSDRV_Heap, 0, buf );
|
ret = 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
HeapFree( PSDRV_Heap, 0, buf );
|
HeapFree( GetProcessHeap(), 0, buf );
|
||||||
return 1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -525,8 +529,7 @@ BOOL PSDRV_WriteSetFont(PHYSDEV dev, const char *name, matrix size, INT escapeme
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
buf = HeapAlloc( PSDRV_Heap, 0, sizeof(pssetfont) +
|
buf = HeapAlloc( GetProcessHeap(), 0, sizeof(pssetfont) + strlen(name) + 40 );
|
||||||
strlen(name) + 40);
|
|
||||||
|
|
||||||
if(!buf) {
|
if(!buf) {
|
||||||
WARN("HeapAlloc failed\n");
|
WARN("HeapAlloc failed\n");
|
||||||
|
@ -536,7 +539,7 @@ BOOL PSDRV_WriteSetFont(PHYSDEV dev, const char *name, matrix size, INT escapeme
|
||||||
sprintf(buf, pssetfont, name, size.xx, size.xy, size.yx, size.yy, -escapement);
|
sprintf(buf, pssetfont, name, size.xx, size.xy, size.yx, size.yy, -escapement);
|
||||||
|
|
||||||
PSDRV_WriteSpool(dev, buf, strlen(buf));
|
PSDRV_WriteSpool(dev, buf, strlen(buf));
|
||||||
HeapFree(PSDRV_Heap, 0, buf);
|
HeapFree( GetProcessHeap(), 0, buf );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -678,7 +681,7 @@ BOOL PSDRV_WriteIndexColorSpaceEnd(PHYSDEV dev)
|
||||||
|
|
||||||
static BOOL PSDRV_WriteRGB(PHYSDEV dev, COLORREF *map, int number)
|
static BOOL PSDRV_WriteRGB(PHYSDEV dev, COLORREF *map, int number)
|
||||||
{
|
{
|
||||||
char *buf = HeapAlloc(PSDRV_Heap, 0, number * 7 + 1), *ptr;
|
char *buf = HeapAlloc( GetProcessHeap(), 0, number * 7 + 1 ), *ptr;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
ptr = buf;
|
ptr = buf;
|
||||||
|
@ -689,13 +692,13 @@ static BOOL PSDRV_WriteRGB(PHYSDEV dev, COLORREF *map, int number)
|
||||||
ptr += 7;
|
ptr += 7;
|
||||||
}
|
}
|
||||||
PSDRV_WriteSpool(dev, buf, number * 7);
|
PSDRV_WriteSpool(dev, buf, number * 7);
|
||||||
HeapFree(PSDRV_Heap, 0, buf);
|
HeapFree( GetProcessHeap(), 0, buf );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL PSDRV_WriteRGBQUAD(PHYSDEV dev, const RGBQUAD *rgb, int number)
|
BOOL PSDRV_WriteRGBQUAD(PHYSDEV dev, const RGBQUAD *rgb, int number)
|
||||||
{
|
{
|
||||||
char *buf = HeapAlloc(PSDRV_Heap, 0, number * 7 + 1), *ptr;
|
char *buf = HeapAlloc( GetProcessHeap(), 0, number * 7 + 1 ), *ptr;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
ptr = buf;
|
ptr = buf;
|
||||||
|
@ -704,7 +707,7 @@ BOOL PSDRV_WriteRGBQUAD(PHYSDEV dev, const RGBQUAD *rgb, int number)
|
||||||
((i & 0x7) == 0x7) || (i == number - 1) ? '\n' : ' ');
|
((i & 0x7) == 0x7) || (i == number - 1) ? '\n' : ' ');
|
||||||
|
|
||||||
PSDRV_WriteSpool(dev, buf, ptr - buf);
|
PSDRV_WriteSpool(dev, buf, ptr - buf);
|
||||||
HeapFree(PSDRV_Heap, 0, buf);
|
HeapFree( GetProcessHeap(), 0, buf );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -720,8 +723,7 @@ static BOOL PSDRV_WriteImageDict(PHYSDEV dev, WORD depth,
|
||||||
|
|
||||||
static const char end[] = " /DataSource currentfile /ASCII85Decode filter /RunLengthDecode filter\n>>\n";
|
static const char end[] = " /DataSource currentfile /ASCII85Decode filter /RunLengthDecode filter\n>>\n";
|
||||||
static const char endbits[] = " /DataSource <%s>\n>>\n";
|
static const char endbits[] = " /DataSource <%s>\n>>\n";
|
||||||
|
char buf[1000];
|
||||||
char *buf = HeapAlloc(PSDRV_Heap, 0, 1000);
|
|
||||||
|
|
||||||
if (top_down)
|
if (top_down)
|
||||||
sprintf(buf, start, widthSrc, heightSrc,
|
sprintf(buf, start, widthSrc, heightSrc,
|
||||||
|
@ -759,7 +761,6 @@ static BOOL PSDRV_WriteImageDict(PHYSDEV dev, WORD depth,
|
||||||
PSDRV_WriteSpool(dev, buf, strlen(buf));
|
PSDRV_WriteSpool(dev, buf, strlen(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapFree(PSDRV_Heap, 0, buf);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -785,7 +786,7 @@ BOOL PSDRV_WriteImage(PHYSDEV dev, WORD depth, INT xDst, INT yDst,
|
||||||
|
|
||||||
BOOL PSDRV_WriteBytes(PHYSDEV dev, const BYTE *bytes, DWORD number)
|
BOOL PSDRV_WriteBytes(PHYSDEV dev, const BYTE *bytes, DWORD number)
|
||||||
{
|
{
|
||||||
char *buf = HeapAlloc(PSDRV_Heap, 0, number * 3 + 1);
|
char *buf = HeapAlloc( GetProcessHeap(), 0, number * 3 + 1 );
|
||||||
char *ptr;
|
char *ptr;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
@ -800,7 +801,7 @@ BOOL PSDRV_WriteBytes(PHYSDEV dev, const BYTE *bytes, DWORD number)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PSDRV_WriteSpool(dev, buf, ptr - buf);
|
PSDRV_WriteSpool(dev, buf, ptr - buf);
|
||||||
HeapFree(PSDRV_Heap, 0, buf);
|
HeapFree( GetProcessHeap(), 0, buf );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -873,7 +874,7 @@ BOOL PSDRV_WriteDIBPatternDict(PHYSDEV dev, const BITMAPINFO *bmi, BYTE *bits, U
|
||||||
w = bmi->bmiHeader.biWidth & ~0x7;
|
w = bmi->bmiHeader.biWidth & ~0x7;
|
||||||
h = bmi->bmiHeader.biHeight & ~0x7;
|
h = bmi->bmiHeader.biHeight & ~0x7;
|
||||||
|
|
||||||
buf = HeapAlloc(PSDRV_Heap, 0, sizeof(do_pattern) + 100);
|
buf = HeapAlloc( GetProcessHeap(), 0, sizeof(do_pattern) + 100 );
|
||||||
ptr = buf;
|
ptr = buf;
|
||||||
for(y = h-1; y >= 0; y--) {
|
for(y = h-1; y >= 0; y--) {
|
||||||
for(x = 0; x < w/8; x++) {
|
for(x = 0; x < w/8; x++) {
|
||||||
|
@ -897,6 +898,6 @@ BOOL PSDRV_WriteDIBPatternDict(PHYSDEV dev, const BITMAPINFO *bmi, BYTE *bits, U
|
||||||
h_mult = (physDev->logPixelsY + 150) / 300;
|
h_mult = (physDev->logPixelsY + 150) / 300;
|
||||||
sprintf(buf, do_pattern, w * w_mult, h * h_mult, w * w_mult, h * h_mult, w * w_mult, h * h_mult);
|
sprintf(buf, do_pattern, w * w_mult, h * h_mult, w * w_mult, h * h_mult, w * w_mult, h * h_mult);
|
||||||
PSDRV_WriteSpool(dev, buf, strlen(buf));
|
PSDRV_WriteSpool(dev, buf, strlen(buf));
|
||||||
HeapFree(PSDRV_Heap, 0, buf);
|
HeapFree( GetProcessHeap(), 0, buf );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue