From: Alex Henrie alexhenrie24@gmail.com
--- dlls/wineps.drv/bitmap.c | 12 +++---- dlls/wineps.drv/clipping.c | 4 +-- dlls/wineps.drv/download.c | 43 ++++++++++++------------ dlls/wineps.drv/escape.c | 4 +-- dlls/wineps.drv/graphics.c | 28 ++++++++-------- dlls/wineps.drv/init.c | 27 +++++++-------- dlls/wineps.drv/pen.c | 4 +-- dlls/wineps.drv/ppd.c | 4 +-- dlls/wineps.drv/ps.c | 61 ++++++++++++++++------------------ dlls/wineps.drv/psdrv.h | 12 ------- dlls/wineps.drv/text.c | 10 +++--- dlls/wineps.drv/type1.c | 68 +++++++++++++++++--------------------- dlls/wineps.drv/type1afm.c | 4 +-- dlls/wineps.drv/type42.c | 35 ++++++++------------ 14 files changed, 144 insertions(+), 172 deletions(-)
diff --git a/dlls/wineps.drv/bitmap.c b/dlls/wineps.drv/bitmap.c index bafc86e9a24..34258c9cd59 100644 --- a/dlls/wineps.drv/bitmap.c +++ b/dlls/wineps.drv/bitmap.c @@ -150,7 +150,7 @@ static inline DWORD max_ascii85_size(DWORD size)
static void CDECL free_heap_bits( struct gdi_image_bits *bits ) { - HeapFree( GetProcessHeap(), 0, bits->ptr ); + free( bits->ptr ); }
/*************************************************************************** @@ -171,14 +171,14 @@ static void PSDRV_WriteImageBits( PHYSDEV dev, const BITMAPINFO *info, BOOL gray PSDRV_WriteImageHeader(dev, info, grayscale, xDst, yDst, widthDst, heightDst, widthSrc, heightSrc);
- rle = HeapAlloc(GetProcessHeap(), 0, max_rle_size(size)); + rle = malloc(max_rle_size(size)); rle_len = RLE_encode(bits, size, rle); - ascii85 = HeapAlloc(GetProcessHeap(), 0, max_ascii85_size(rle_len)); + ascii85 = malloc(max_ascii85_size(rle_len)); ascii85_len = ASCII85_encode(rle, rle_len, ascii85); - HeapFree(GetProcessHeap(), 0, rle); + free(rle); PSDRV_WriteData(dev, ascii85, ascii85_len); PSDRV_WriteSpool(dev, "~>\n", 3); - HeapFree(GetProcessHeap(), 0, ascii85); + free(ascii85); }
/*********************************************************************** @@ -222,7 +222,7 @@ DWORD CDECL PSDRV_PutImage( PHYSDEV dev, HRGN clip, BITMAPINFO *info,
if (src_stride != dst_stride || (info->bmiHeader.biBitCount == 24 && !bits->is_copy)) { - if (!(dst_bits.ptr = HeapAlloc( GetProcessHeap(), 0, size ))) return ERROR_OUTOFMEMORY; + if (!(dst_bits.ptr = malloc( size ))) return ERROR_OUTOFMEMORY; dst_bits.is_copy = TRUE; dst_bits.free = free_heap_bits; } diff --git a/dlls/wineps.drv/clipping.c b/dlls/wineps.drv/clipping.c index 62022c97c03..eeb6acfaa0b 100644 --- a/dlls/wineps.drv/clipping.c +++ b/dlls/wineps.drv/clipping.c @@ -35,7 +35,7 @@ void PSDRV_AddClip( PHYSDEV dev, HRGN hrgn ) DWORD i, size = GetRegionData(hrgn, 0, NULL);
if (!size) return; - if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return; + if (!(data = malloc(size))) return; GetRegionData( hrgn, size, data ); rect = (RECT *)data->Buffer;
@@ -62,7 +62,7 @@ void PSDRV_AddClip( PHYSDEV dev, HRGN hrgn ) PSDRV_WriteRectClip2(dev, szArrayName); break; } - HeapFree( GetProcessHeap(), 0, data ); + free(data); }
/*********************************************************************** diff --git a/dlls/wineps.drv/download.c b/dlls/wineps.drv/download.c index e8c3299e17c..d2ad0171845 100644 --- a/dlls/wineps.drv/download.c +++ b/dlls/wineps.drv/download.c @@ -60,7 +60,7 @@ static void get_download_name(PHYSDEV dev, LPOUTLINETEXTMETRICA potm, char **str size = GetFontData(dev->hdc, MS_MAKE_TAG('n','a','m','e'), 0, NULL, 0); if(size != 0 && size != GDI_ERROR) { - BYTE *name = HeapAlloc(GetProcessHeap(), 0, size); + BYTE *name = malloc(size); if(name) { USHORT count, i; @@ -92,16 +92,16 @@ static void get_download_name(PHYSDEV dev, LPOUTLINETEXTMETRICA potm, char **str name_record->language_id == 0 && name_record->name_id == 6) { TRACE("Got Mac PS name %s\n", debugstr_an((char*)strings + name_record->offset, name_record->length)); - *str = HeapAlloc(GetProcessHeap(), 0, name_record->length + sizeof(vertical_suffix)); + *str = malloc(name_record->length + sizeof(vertical_suffix)); memcpy(*str, strings + name_record->offset, name_record->length); *(*str + name_record->length) = '\0'; - HeapFree(GetProcessHeap(), 0, name); + free(name); goto done; } if(name_record->platform_id == 3 && name_record->encoding_id == 1 && name_record->language_id == 0x409 && name_record->name_id == 6) { - WCHAR *unicode = HeapAlloc(GetProcessHeap(), 0, name_record->length + 2); + WCHAR *unicode = malloc(name_record->length + 2); DWORD len; int c;
@@ -110,20 +110,20 @@ static void get_download_name(PHYSDEV dev, LPOUTLINETEXTMETRICA potm, char **str unicode[c] = 0; TRACE("Got Windows PS name %s\n", debugstr_w(unicode)); len = WideCharToMultiByte(1252, 0, unicode, -1, NULL, 0, NULL, NULL); - *str = HeapAlloc(GetProcessHeap(), 0, len + sizeof(vertical_suffix) - 1); + *str = malloc(len + sizeof(vertical_suffix) - 1); WideCharToMultiByte(1252, 0, unicode, -1, *str, len, NULL, NULL); - HeapFree(GetProcessHeap(), 0, unicode); - HeapFree(GetProcessHeap(), 0, name); + free(unicode); + free(name); goto done; } } TRACE("Unable to find PostScript name\n"); - HeapFree(GetProcessHeap(), 0, name); + free(name); } }
len = strlen((char*)potm + (ptrdiff_t)potm->otmpFaceName) + 1; - *str = HeapAlloc(GetProcessHeap(),0,len + sizeof(vertical_suffix) - 1); + *str = malloc(len + sizeof(vertical_suffix) - 1); strcpy(*str, (char*)potm + (ptrdiff_t)potm->otmpFaceName);
done: @@ -282,7 +282,7 @@ BOOL PSDRV_WriteSetDownloadFont(PHYSDEV dev, BOOL vertical) if (!GetObjectW( GetCurrentObject(dev->hdc, OBJ_FONT), sizeof(lf), &lf )) return FALSE;
- potm = HeapAlloc(GetProcessHeap(), 0, len); + potm = malloc(len); if (!potm) return FALSE;
@@ -318,17 +318,16 @@ BOOL PSDRV_WriteSetDownloadFont(PHYSDEV dev, BOOL vertical) UINT emsize = get_bbox(dev->hdc, &bbox);
if (!emsize) { - HeapFree(GetProcessHeap(), 0, ps_name); - HeapFree(GetProcessHeap(), 0, potm); + free(ps_name); + free(potm); return FALSE; } if(!is_room_for_font(physDev)) PSDRV_EmptyDownloadList(dev, TRUE);
- pdl = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pdl)); - pdl->ps_name = HeapAlloc(GetProcessHeap(), 0, strlen(ps_name)+1); - strcpy(pdl->ps_name, ps_name); - pdl->next = NULL; + pdl = calloc(1, sizeof(*pdl)); + pdl->ps_name = strdup(ps_name); + pdl->next = NULL;
if(physDev->pi->ppd->TTRasterizer == RO_Type42) { pdl->typeinfo.Type42 = T42_download_header(dev, ps_name, &bbox, emsize); @@ -356,8 +355,8 @@ BOOL PSDRV_WriteSetDownloadFont(PHYSDEV dev, BOOL vertical) PSDRV_WriteSetFont(dev, ps_name, physDev->font.size, escapement, is_fake_italic( dev->hdc ));
- HeapFree(GetProcessHeap(), 0, ps_name); - HeapFree(GetProcessHeap(), 0, potm); + free(ps_name); + free(potm); return TRUE; }
@@ -696,7 +695,7 @@ void get_glyph_name(HDC hdc, WORD index, char *name) size = GetFontData(hdc, MS_MAKE_TAG('p','o','s','t'), 0, NULL, 0); if(size < sizeof(*post_header) || size == GDI_ERROR) return; - post_header = HeapAlloc(GetProcessHeap(), 0, size); + post_header = malloc(size); if(!post_header) return; size = GetFontData(hdc, MS_MAKE_TAG('p','o','s','t'), 0, post_header, size); if(size < sizeof(*post_header) || size == GDI_ERROR) @@ -736,7 +735,7 @@ void get_glyph_name(HDC hdc, WORD index, char *name) HIWORD(post_header->format), LOWORD(post_header->format));
cleanup: - HeapFree(GetProcessHeap(), 0, post_header); + free(post_header); }
/**************************************************************************** @@ -819,10 +818,10 @@ BOOL PSDRV_EmptyDownloadList(PHYSDEV dev, BOOL write_undef) assert(0); }
- HeapFree(GetProcessHeap(), 0, pdl->ps_name); + free(pdl->ps_name); old = pdl; pdl = pdl->next; - HeapFree(GetProcessHeap(), 0, old); + free(old); } return TRUE; } diff --git a/dlls/wineps.drv/escape.c b/dlls/wineps.drv/escape.c index 0149e192520..c6cdb23f1c6 100644 --- a/dlls/wineps.drv/escape.c +++ b/dlls/wineps.drv/escape.c @@ -490,7 +490,7 @@ INT CDECL PSDRV_StartDoc( PHYSDEV dev, const DOCINFOW *doc ) physDev->job.PageNo = 0; physDev->job.quiet = FALSE; physDev->job.passthrough_state = passthrough_none; - physDev->job.doc_name = strdupW( doc->lpszDocName ); + physDev->job.doc_name = wcsdup(doc->lpszDocName);
return physDev->job.id; } @@ -522,7 +522,7 @@ INT CDECL PSDRV_EndDoc( PHYSDEV dev ) ClosePrinter(physDev->job.hprinter); physDev->job.hprinter = NULL; physDev->job.id = 0; - HeapFree( GetProcessHeap(), 0, physDev->job.doc_name ); + free(physDev->job.doc_name); physDev->job.doc_name = NULL;
return ret; diff --git a/dlls/wineps.drv/graphics.c b/dlls/wineps.drv/graphics.c index 45f20728183..14ebe3e59f0 100644 --- a/dlls/wineps.drv/graphics.c +++ b/dlls/wineps.drv/graphics.c @@ -310,7 +310,7 @@ BOOL CDECL PSDRV_PolyPolyline( PHYSDEV dev, const POINT* pts, const DWORD* count TRACE("\n");
for (polyline = total = 0; polyline < polylines; polyline++) total += counts[polyline]; - if (!(dev_pts = HeapAlloc( GetProcessHeap(), 0, total * sizeof(*dev_pts) ))) return FALSE; + if (!(dev_pts = malloc( total * sizeof(*dev_pts) ))) return FALSE; memcpy( dev_pts, pts, total * sizeof(*dev_pts) ); LPtoDP( dev->hdc, dev_pts, total );
@@ -326,7 +326,7 @@ BOOL CDECL PSDRV_PolyPolyline( PHYSDEV dev, const POINT* pts, const DWORD* count for(line = 1; line < counts[polyline]; line++, pt++) PSDRV_WriteLineTo(dev, pt->x, pt->y); } - HeapFree( GetProcessHeap(), 0, dev_pts ); + free( dev_pts );
PSDRV_DrawLine(dev); PSDRV_ResetClip(dev); @@ -346,7 +346,7 @@ BOOL CDECL PSDRV_PolyPolygon( PHYSDEV dev, const POINT* pts, const INT* counts, TRACE("\n");
for (polygon = total = 0; polygon < polygons; polygon++) total += counts[polygon]; - if (!(dev_pts = HeapAlloc( GetProcessHeap(), 0, total * sizeof(*dev_pts) ))) return FALSE; + if (!(dev_pts = malloc( total * sizeof(*dev_pts) ))) return FALSE; memcpy( dev_pts, pts, total * sizeof(*dev_pts) ); LPtoDP( dev->hdc, dev_pts, total );
@@ -363,7 +363,7 @@ BOOL CDECL PSDRV_PolyPolygon( PHYSDEV dev, const POINT* pts, const INT* counts, PSDRV_WriteLineTo(dev, pt->x, pt->y); PSDRV_WriteClosePath(dev); } - HeapFree( GetProcessHeap(), 0, dev_pts ); + free( dev_pts );
if(GetPolyFillMode( dev->hdc ) == ALTERNATE) PSDRV_Brush(dev, 1); @@ -386,7 +386,7 @@ BOOL CDECL PSDRV_PolyBezier( PHYSDEV dev, const POINT *pts, DWORD count )
TRACE("\n");
- if (!(dev_pts = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*dev_pts) ))) return FALSE; + if (!(dev_pts = malloc( count * sizeof(*dev_pts) ))) return FALSE; memcpy( dev_pts, pts, count * sizeof(*dev_pts) ); LPtoDP( dev->hdc, dev_pts, count );
@@ -397,7 +397,7 @@ BOOL CDECL PSDRV_PolyBezier( PHYSDEV dev, const POINT *pts, DWORD count ) for (i = 1; i < count; i += 3) PSDRV_WriteCurveTo( dev, dev_pts + i ); PSDRV_DrawLine(dev); PSDRV_ResetClip(dev); - HeapFree( GetProcessHeap(), 0, dev_pts ); + free( dev_pts ); return TRUE; }
@@ -413,7 +413,7 @@ BOOL CDECL PSDRV_PolyBezierTo( PHYSDEV dev, const POINT *pts, DWORD count ) TRACE("\n");
count++; /* add initial position */ - if (!(dev_pts = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*dev_pts) ))) return FALSE; + if (!(dev_pts = malloc( count * sizeof(*dev_pts) ))) return FALSE; GetCurrentPositionEx( dev->hdc, dev_pts ); memcpy( dev_pts + 1, pts, (count - 1) * sizeof(*dev_pts) ); LPtoDP( dev->hdc, dev_pts, count ); @@ -425,7 +425,7 @@ BOOL CDECL PSDRV_PolyBezierTo( PHYSDEV dev, const POINT *pts, DWORD count ) for (i = 1; i < count; i += 3) PSDRV_WriteCurveTo( dev, dev_pts + i ); PSDRV_DrawLine(dev); PSDRV_ResetClip(dev); - HeapFree( GetProcessHeap(), 0, dev_pts ); + free( dev_pts ); return TRUE; }
@@ -467,7 +467,7 @@ BOOL CDECL PSDRV_PaintRgn( PHYSDEV dev, HRGN hrgn ) TRACE("hdc=%p\n", dev->hdc);
size = GetRegionData(hrgn, 0, NULL); - rgndata = HeapAlloc( GetProcessHeap(), 0, size ); + rgndata = malloc( size ); if(!rgndata) { ERR("Can't allocate buffer\n"); return FALSE; @@ -488,7 +488,7 @@ BOOL CDECL PSDRV_PaintRgn( PHYSDEV dev, HRGN hrgn ) PSDRV_ResetClip(dev);
end: - HeapFree(GetProcessHeap(), 0, rgndata); + free( rgndata); return TRUE; }
@@ -505,8 +505,8 @@ static BOOL paint_path( PHYSDEV dev, BOOL stroke, BOOL fill ) AbortPath( dev->hdc ); return TRUE; } - points = HeapAlloc( GetProcessHeap(), 0, size * sizeof(*points) ); - types = HeapAlloc( GetProcessHeap(), 0, size * sizeof(*types) ); + points = malloc( size * sizeof(*points) ); + types = malloc( size * sizeof(*types) ); if (!points || !types) goto done; if (GetPath( dev->hdc, points, types, size ) == -1) goto done; LPtoDP( dev->hdc, points, size ); @@ -540,8 +540,8 @@ static BOOL paint_path( PHYSDEV dev, BOOL stroke, BOOL fill ) AbortPath( dev->hdc );
done: - HeapFree( GetProcessHeap(), 0, points ); - HeapFree( GetProcessHeap(), 0, types ); + free( points ); + free( types ); return ret; }
diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c index 0d4467b6964..46ee4a03cf6 100644 --- a/dlls/wineps.drv/init.c +++ b/dlls/wineps.drv/init.c @@ -20,6 +20,7 @@ */
#include <stdarg.h> +#include <stdlib.h> #include <string.h>
#include "windef.h" @@ -342,13 +343,13 @@ static PSDRV_PDEVICE *create_psdrv_physdev( PRINTERINFO *pi ) { PSDRV_PDEVICE *physDev;
- physDev = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*physDev) ); + physDev = calloc( 1, sizeof(*physDev) ); if (!physDev) return NULL;
- physDev->Devmode = HeapAlloc( GetProcessHeap(), 0, sizeof(PSDRV_DEVMODE) ); + physDev->Devmode = malloc( sizeof(PSDRV_DEVMODE) ); if (!physDev->Devmode) { - HeapFree( GetProcessHeap(), 0, physDev ); + free( physDev ); return NULL; }
@@ -387,7 +388,7 @@ static BOOL CDECL PSDRV_CreateDC( PHYSDEV *pdev, LPCWSTR device, LPCWSTR output,
if (!(physDev = create_psdrv_physdev( pi ))) return FALSE;
- if (output && *output) physDev->job.output = strdupW( output ); + if (output && *output) physDev->job.output = wcsdup( output );
if(initData) { @@ -431,9 +432,9 @@ static BOOL CDECL PSDRV_DeleteDC( PHYSDEV dev )
TRACE("\n");
- HeapFree( GetProcessHeap(), 0, physDev->Devmode ); - HeapFree( GetProcessHeap(), 0, physDev->job.output ); - HeapFree( GetProcessHeap(), 0, physDev ); + free( physDev->Devmode ); + free( physDev->job.output ); + free( physDev );
return TRUE; } @@ -632,7 +633,7 @@ static WCHAR *get_ppd_filename( HANDLE printer )
GetPrinterDriverW( printer, NULL, 2, NULL, 0, &needed ); if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return NULL; - info = HeapAlloc( GetProcessHeap(), 0, needed ); + info = malloc( needed ); if (!info) return NULL; GetPrinterDriverW( printer, NULL, 2, (BYTE*)info, needed, &needed ); name = (WCHAR *)info; @@ -676,7 +677,7 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCWSTR name) }
len = WideCharToMultiByte( CP_ACP, 0, name, -1, NULL, 0, NULL, NULL ); - nameA = HeapAlloc( GetProcessHeap(), 0, len ); + nameA = malloc( len ); WideCharToMultiByte( CP_ACP, 0, name, -1, nameA, len, NULL, NULL );
pi->Devmode = get_devmode( hPrinter, name, &using_default_devmode ); @@ -748,8 +749,8 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCWSTR name)
} ClosePrinter( hPrinter ); - HeapFree( GetProcessHeap(), 0, nameA ); - HeapFree( GetProcessHeap(), 0, ppd_filename ); + free( nameA ); + free( ppd_filename ); list_add_head( &printer_list, &pi->entry ); return pi;
@@ -759,8 +760,8 @@ fail: HeapFree(PSDRV_Heap, 0, pi->friendly_name); HeapFree(PSDRV_Heap, 0, pi->Devmode); HeapFree(PSDRV_Heap, 0, pi); - HeapFree( GetProcessHeap(), 0, nameA ); - HeapFree( GetProcessHeap(), 0, ppd_filename ); + free(nameA); + free(ppd_filename); return NULL; }
diff --git a/dlls/wineps.drv/pen.c b/dlls/wineps.drv/pen.c index c0dcb51abda..6d9e7d32007 100644 --- a/dlls/wineps.drv/pen.c +++ b/dlls/wineps.drv/pen.c @@ -50,7 +50,7 @@ HPEN CDECL PSDRV_SelectPen( PHYSDEV dev, HPEN hpen, const struct brush_pattern *
if (!size) return 0;
- elp = HeapAlloc( GetProcessHeap(), 0, size ); + elp = malloc( size );
GetObjectW( hpen, size, elp ); /* FIXME: add support for user style pens */ @@ -132,7 +132,7 @@ HPEN CDECL PSDRV_SelectPen( PHYSDEV dev, HPEN hpen, const struct brush_pattern * physDev->pen.dash_len = 0; }
- HeapFree( GetProcessHeap(), 0, elp ); + free( elp ); physDev->pen.set = FALSE; return hpen; } diff --git a/dlls/wineps.drv/ppd.c b/dlls/wineps.drv/ppd.c index 66d35bab9c6..dc28c558205 100644 --- a/dlls/wineps.drv/ppd.c +++ b/dlls/wineps.drv/ppd.c @@ -774,7 +774,7 @@ PPD *PSDRV_ParsePPD( const WCHAR *fname, HANDLE printer )
TRACE("Resolution %ldx%ld, invocation %s\n", sz.cx, sz.cy, tuple.value);
- res = HeapAlloc( GetProcessHeap(), 0, sizeof(*res) ); + res = malloc( sizeof(*res) ); res->resx = sz.cx; res->resy = sz.cy; res->InvocationString = tuple.value; @@ -982,7 +982,7 @@ PPD *PSDRV_ParsePPD( const WCHAR *fname, HANDLE printer )
else if(!strcmp("*Duplex", tuple.key)) { - DUPLEX *duplex = HeapAlloc( GetProcessHeap(), 0, sizeof(*duplex) ); + DUPLEX *duplex = malloc( sizeof(*duplex) ); duplex->Name = tuple.option; duplex->FullName = tuple.opttrans; duplex->InvocationString = tuple.value; diff --git a/dlls/wineps.drv/ps.c b/dlls/wineps.drv/ps.c index 7f7841d7ca7..0efe181488d 100644 --- a/dlls/wineps.drv/ps.c +++ b/dlls/wineps.drv/ps.c @@ -269,15 +269,14 @@ DWORD PSDRV_WriteSpool(PHYSDEV dev, LPCSTR lpData, DWORD cch) static INT PSDRV_WriteFeature(PHYSDEV dev, LPCSTR feature, LPCSTR value, LPCSTR invocation) {
- char *buf = HeapAlloc( GetProcessHeap(), 0, sizeof(psbeginfeature) + - strlen(feature) + strlen(value)); + char *buf = malloc( sizeof(psbeginfeature) + strlen(feature) + strlen(value) );
sprintf(buf, psbeginfeature, feature, value); write_spool( dev, buf, strlen(buf) ); write_spool( dev, invocation, strlen(invocation) ); write_spool( dev, psendfeature, strlen(psendfeature) );
- HeapFree( GetProcessHeap(), 0, buf ); + free( buf ); return 1; }
@@ -296,13 +295,12 @@ static char *escape_title(LPCWSTR wstr)
if(!wstr) { - ret = HeapAlloc(GetProcessHeap(), 0, 1); - *ret = '\0'; + ret = strdup( "" ); return ret; }
i = WideCharToMultiByte( CP_ACP, 0, wstr, -1, NULL, 0, NULL, NULL ); - str = HeapAlloc( GetProcessHeap(), 0, i ); + str = malloc( i ); if (!str) return NULL; WideCharToMultiByte( CP_ACP, 0, wstr, -1, str, i, NULL, NULL );
@@ -314,14 +312,14 @@ static char *escape_title(LPCWSTR wstr)
if(!extra) { - ret = HeapAlloc(GetProcessHeap(), 0, i + 1); + ret = malloc(i + 1); memcpy(ret, str, i); ret[i] = '\0'; goto done; }
extra += 2; /* two for the brackets */ - cp = ret = HeapAlloc(GetProcessHeap(), 0, i + extra + 1); + cp = ret = malloc(i + extra + 1); *cp++ = '('; for(i = 0; i < 0x80 && str[i]; i++) { @@ -340,7 +338,7 @@ static char *escape_title(LPCWSTR wstr) *cp = '\0';
done: - HeapFree( GetProcessHeap(), 0, str ); + free(str); return ret; }
@@ -426,11 +424,10 @@ INT PSDRV_WriteHeader( PHYSDEV dev, LPCWSTR title ) write_cups_job_ticket( dev, &ticket_info );
escaped_title = escape_title(title); - buf = HeapAlloc( GetProcessHeap(), 0, sizeof(psheader) + - strlen(escaped_title) + 30 ); + buf = malloc(sizeof(psheader) + strlen(escaped_title) + 30); if(!buf) { - WARN("HeapAlloc failed\n"); - HeapFree(GetProcessHeap(), 0, escaped_title); + WARN("malloc failed\n"); + free(escaped_title); return 0; }
@@ -445,11 +442,11 @@ INT PSDRV_WriteHeader( PHYSDEV dev, LPCWSTR title ) dmOrientation = (physDev->Devmode->dmPublic.dmOrientation == DMORIENT_LANDSCAPE ? "Landscape" : "Portrait"); sprintf(buf, psheader, escaped_title, llx, lly, urx, ury, dmOrientation);
- HeapFree(GetProcessHeap(), 0, escaped_title); + free(escaped_title);
len = strlen( buf ); write_spool( dev, buf, len ); - HeapFree( GetProcessHeap(), 0, buf ); + free( buf );
write_spool( dev, psbeginprolog, strlen(psbeginprolog) ); write_spool( dev, psprolog, strlen(psprolog) ); @@ -478,9 +475,9 @@ INT PSDRV_WriteFooter( PHYSDEV dev ) char *buf; int ret = 1;
- buf = HeapAlloc( GetProcessHeap(), 0, sizeof(psfooter) + 100 ); + buf = malloc( sizeof(psfooter) + 100 ); if(!buf) { - WARN("HeapAlloc failed\n"); + WARN("malloc failed\n"); return 0; }
@@ -490,7 +487,7 @@ INT PSDRV_WriteFooter( PHYSDEV dev ) WARN("WriteSpool error\n"); ret = 0; } - HeapFree( GetProcessHeap(), 0, buf ); + free( buf ); return ret; }
@@ -518,9 +515,9 @@ INT PSDRV_WriteNewPage( PHYSDEV dev )
sprintf(name, "%d", physDev->job.PageNo);
- buf = HeapAlloc( GetProcessHeap(), 0, sizeof(psnewpage) + 200 ); + buf = malloc( sizeof(psnewpage) + 200 ); if(!buf) { - WARN("HeapAlloc failed\n"); + WARN("malloc failed\n"); return 0; }
@@ -548,7 +545,7 @@ INT PSDRV_WriteNewPage( PHYSDEV dev ) WARN("WriteSpool error\n"); ret = 0; } - HeapFree( GetProcessHeap(), 0, buf ); + free( buf ); return ret; }
@@ -611,10 +608,10 @@ BOOL PSDRV_WriteSetFont(PHYSDEV dev, const char *name, matrix size, INT escapeme { char *buf;
- buf = HeapAlloc( GetProcessHeap(), 0, strlen(name) + 256 ); + buf = malloc( strlen(name) + 256 );
if(!buf) { - WARN("HeapAlloc failed\n"); + WARN("malloc failed\n"); return FALSE; }
@@ -635,7 +632,7 @@ BOOL PSDRV_WriteSetFont(PHYSDEV dev, const char *name, matrix size, INT escapeme }
PSDRV_WriteSpool( dev, pssetfont, sizeof(pssetfont) - 1 ); - HeapFree( GetProcessHeap(), 0, buf ); + free( buf );
return TRUE; } @@ -778,7 +775,7 @@ BOOL PSDRV_WriteIndexColorSpaceEnd(PHYSDEV dev)
static BOOL PSDRV_WriteRGB(PHYSDEV dev, COLORREF *map, int number) { - char *buf = HeapAlloc( GetProcessHeap(), 0, number * 7 + 1 ), *ptr; + char *buf = malloc(number * 7 + 1), *ptr; int i;
ptr = buf; @@ -789,13 +786,13 @@ static BOOL PSDRV_WriteRGB(PHYSDEV dev, COLORREF *map, int number) ptr += 7; } PSDRV_WriteSpool(dev, buf, number * 7); - HeapFree( GetProcessHeap(), 0, buf ); + free(buf); return TRUE; }
BOOL PSDRV_WriteRGBQUAD(PHYSDEV dev, const RGBQUAD *rgb, int number) { - char *buf = HeapAlloc( GetProcessHeap(), 0, number * 7 + 1 ), *ptr; + char *buf = malloc(number * 7 + 1), *ptr; int i;
ptr = buf; @@ -804,7 +801,7 @@ BOOL PSDRV_WriteRGBQUAD(PHYSDEV dev, const RGBQUAD *rgb, int number) ((i & 0x7) == 0x7) || (i == number - 1) ? '\n' : ' ');
PSDRV_WriteSpool(dev, buf, ptr - buf); - HeapFree( GetProcessHeap(), 0, buf ); + free(buf); return TRUE; }
@@ -886,7 +883,7 @@ BOOL PSDRV_WriteImage(PHYSDEV dev, WORD depth, BOOL grayscale, INT xDst, INT yDs
BOOL PSDRV_WriteBytes(PHYSDEV dev, const BYTE *bytes, DWORD number) { - char *buf = HeapAlloc( GetProcessHeap(), 0, number * 3 + 1 ); + char *buf = malloc(number * 3 + 1); char *ptr; unsigned int i;
@@ -901,7 +898,7 @@ BOOL PSDRV_WriteBytes(PHYSDEV dev, const BYTE *bytes, DWORD number) } } PSDRV_WriteSpool(dev, buf, ptr - buf); - HeapFree( GetProcessHeap(), 0, buf ); + free(buf); return TRUE; }
@@ -974,7 +971,7 @@ BOOL PSDRV_WriteDIBPatternDict(PHYSDEV dev, const BITMAPINFO *bmi, BYTE *bits, U w = bmi->bmiHeader.biWidth & ~0x7; h = abs_height & ~0x7;
- buf = HeapAlloc( GetProcessHeap(), 0, sizeof(do_pattern) + 100 ); + buf = malloc(sizeof(do_pattern) + 100); ptr = buf; for(y = h-1; y >= 0; y--) { for(x = 0; x < w/8; x++) { @@ -998,6 +995,6 @@ BOOL PSDRV_WriteDIBPatternDict(PHYSDEV dev, const BITMAPINFO *bmi, BYTE *bits, U 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); PSDRV_WriteSpool(dev, buf, strlen(buf)); - HeapFree( GetProcessHeap(), 0, buf ); + free(buf); return TRUE; } diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h index 2af021508b7..1f1b61b22e4 100644 --- a/dlls/wineps.drv/psdrv.h +++ b/dlls/wineps.drv/psdrv.h @@ -583,16 +583,4 @@ extern void passthrough_leave(PHYSDEV dev) DECLSPEC_HIDDEN; setlocale(LC_NUMERIC,tmplocale); \ } while (0)
-static inline WCHAR *strdupW( const WCHAR *str ) -{ - int size; - WCHAR *ret; - - if (!str) return NULL; - size = (lstrlenW( str ) + 1) * sizeof(WCHAR); - ret = HeapAlloc( GetProcessHeap(), 0, size ); - if (ret) memcpy( ret, str, size ); - return ret; -} - #endif diff --git a/dlls/wineps.drv/text.c b/dlls/wineps.drv/text.c index 767b1529c24..cc6d105856a 100644 --- a/dlls/wineps.drv/text.c +++ b/dlls/wineps.drv/text.c @@ -61,7 +61,7 @@ static Run* build_vertical_runs(PHYSDEV dev, UINT flags, LPCWSTR str, UINT count BOOL last_vert; INT start, end; INT array_size = 5; - Run *run = HeapAlloc(GetProcessHeap(),0,sizeof(Run)*array_size); + Run *run = malloc(sizeof(Run)*array_size); int index = 0; LOGFONTW lf;
@@ -107,7 +107,7 @@ static Run* build_vertical_runs(PHYSDEV dev, UINT flags, LPCWSTR str, UINT count if (index >= array_size) { array_size *=2; - run = HeapReAlloc(GetProcessHeap(), 0, run, sizeof(Run)*array_size); + run = realloc(run, sizeof(Run) * array_size); } start = end; if (start < count) @@ -198,7 +198,7 @@ BOOL CDECL PSDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT * PSDRV_ResetClip(dev); }
- HeapFree(GetProcessHeap(),0,runs); + free(runs); return bResult; }
@@ -216,7 +216,7 @@ static BOOL PSDRV_Text(PHYSDEV dev, INT x, INT y, UINT flags, LPCWSTR str,
if(physDev->font.fontloc == Download && !(flags & ETO_GLYPH_INDEX)) { - glyphs = HeapAlloc( GetProcessHeap(), 0, count * sizeof(WORD) ); + glyphs = malloc( count * sizeof(WORD) ); GetGlyphIndicesW( dev->hdc, str, count, glyphs, 0 ); str = glyphs; } @@ -253,6 +253,6 @@ static BOOL PSDRV_Text(PHYSDEV dev, INT x, INT y, UINT flags, LPCWSTR str, PSDRV_WriteBuiltinGlyphShow(dev, str + i, 1); }
- HeapFree( GetProcessHeap(), 0, glyphs ); + free( glyphs ); return TRUE; } diff --git a/dlls/wineps.drv/type1.c b/dlls/wineps.drv/type1.c index f31c6dd3bee..abedff57fc1 100644 --- a/dlls/wineps.drv/type1.c +++ b/dlls/wineps.drv/type1.c @@ -96,23 +96,20 @@ TYPE1 *T1_download_header(PHYSDEV dev, char *ps_name, RECT *bbox, UINT emsize) " end\n" "currentdict end dup /FontName get exch definefont pop\n";
- t1 = HeapAlloc(GetProcessHeap(), 0, sizeof(*t1)); + t1 = malloc(sizeof(*t1)); t1->emsize = emsize;
t1->glyph_sent_size = GLYPH_SENT_INC; - t1->glyph_sent = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - t1->glyph_sent_size * - sizeof(*(t1->glyph_sent))); + t1->glyph_sent = calloc(t1->glyph_sent_size, sizeof(*(t1->glyph_sent)));
- buf = HeapAlloc(GetProcessHeap(), 0, sizeof(dict) + strlen(ps_name) + - 100); + buf = malloc(sizeof(dict) + strlen(ps_name) + 100);
sprintf(buf, dict, ps_name, t1->emsize, t1->emsize, bbox->left, bbox->bottom, bbox->right, bbox->top);
PSDRV_WriteSpool(dev, buf, strlen(buf));
- HeapFree(GetProcessHeap(), 0, buf); + free(buf); return t1; }
@@ -124,24 +121,24 @@ typedef struct {
static STR *str_init(int sz) { - STR *str = HeapAlloc(GetProcessHeap(), 0, sizeof(*str)); + STR *str = malloc(sizeof(*str)); str->max_len = sz; - str->str = HeapAlloc(GetProcessHeap(), 0, str->max_len); + str->str = malloc(str->max_len); str->len = 0; return str; }
static void str_free(STR *str) { - HeapFree(GetProcessHeap(), 0, str->str); - HeapFree(GetProcessHeap(), 0, str); + free(str->str); + free(str); }
static void str_add_byte(STR *str, BYTE b) { if(str->len == str->max_len) { str->max_len *= 2; - str->str = HeapReAlloc(GetProcessHeap(), 0, str->str, str->max_len); + str->str = realloc(str->str, str->max_len); } str->str[str->len++] = b; } @@ -224,7 +221,7 @@ static BOOL get_glyf_pos(HDC hdc, DWORD index, DWORD *start, DWORD *end)
len = GetFontData(hdc, MS_MAKE_TAG('h','e','a','d'), 0, NULL, 0); if (len == GDI_ERROR) return FALSE; - head = HeapAlloc(GetProcessHeap(), 0, len); + head = malloc(len); GetFontData(hdc, MS_MAKE_TAG('h','e','a','d'), 0, head, len); loca_format = get_be_word(head + 50);
@@ -234,10 +231,10 @@ static BOOL get_glyf_pos(HDC hdc, DWORD index, DWORD *start, DWORD *end) len = GetFontData(hdc, MS_MAKE_TAG('C','F','F',' '), 0, NULL, 0); if (len != GDI_ERROR) FIXME( "CFF tables not supported yet\n" ); else ERR( "loca table not found\n" ); - HeapFree(GetProcessHeap(), 0, head); + free(head); return FALSE; } - loca = HeapAlloc(GetProcessHeap(), 0, len); + loca = malloc(len); GetFontData(hdc, MS_MAKE_TAG('l','o','c','a'), 0, loca, len);
switch(loca_format) { @@ -257,8 +254,8 @@ static BOOL get_glyf_pos(HDC hdc, DWORD index, DWORD *start, DWORD *end) ERR("Unknown loca_format %d\n", loca_format); }
- HeapFree(GetProcessHeap(), 0, loca); - HeapFree(GetProcessHeap(), 0, head); + free(loca); + free(head); return ret; }
@@ -274,12 +271,12 @@ static BYTE *get_glyph_data(HDC hdc, DWORD index) len = end - start; if(!len) return NULL;
- data = HeapAlloc(GetProcessHeap(), 0, len); + data = malloc(len); if(!data) return NULL;
if(GetFontData(hdc, MS_MAKE_TAG('g','l','y','f'), start, data, len) != len) { - HeapFree(GetProcessHeap(), 0, data); + free(data); return NULL; } return data; @@ -329,15 +326,15 @@ static BOOL append_simple_glyph(BYTE *data, glyph_outline *outline)
if(outline->num_conts) { - outline->end_pts = HeapReAlloc(GetProcessHeap(), 0, outline->end_pts, (start_cont + num_conts) * sizeof(*outline->end_pts)); - outline->flags = HeapReAlloc(GetProcessHeap(), 0, outline->flags, start_pt + num_pts); - outline->pts = HeapReAlloc(GetProcessHeap(), 0, outline->pts, (start_pt + num_pts) * sizeof(*outline->pts)); + outline->end_pts = realloc(outline->end_pts, (start_cont + num_conts) * sizeof(*outline->end_pts)); + outline->flags = realloc(outline->flags, start_pt + num_pts); + outline->pts = realloc(outline->pts, (start_pt + num_pts) * sizeof(*outline->pts)); } else { - outline->end_pts = HeapAlloc(GetProcessHeap(), 0, num_conts * sizeof(*outline->end_pts)); - outline->flags = HeapAlloc(GetProcessHeap(), 0, num_pts); - outline->pts = HeapAlloc(GetProcessHeap(), 0, num_pts * sizeof(*outline->pts)); + outline->end_pts = malloc(num_conts * sizeof(*outline->end_pts)); + outline->flags = malloc(num_pts); + outline->pts = malloc(num_pts * sizeof(*outline->pts)); }
outline->num_conts += num_conts; @@ -521,7 +518,7 @@ static BOOL append_glyph_outline(HDC hdc, DWORD index, glyph_outline *outline) else if(num_conts > 0) append_simple_glyph(glyph_data, outline);
- HeapFree(GetProcessHeap(), 0, glyph_data); + free(glyph_data); return TRUE; }
@@ -559,9 +556,7 @@ BOOL T1_download_glyph(PHYSDEV dev, DOWNLOAD *pdl, DWORD index, char *glyph_name return TRUE; } else { t1->glyph_sent_size = (index / GLYPH_SENT_INC + 1) * GLYPH_SENT_INC; - t1->glyph_sent = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - t1->glyph_sent, - t1->glyph_sent_size * sizeof(*(t1->glyph_sent))); + t1->glyph_sent = _recalloc(t1->glyph_sent, t1->glyph_sent_size, sizeof(*(t1->glyph_sent))); }
outline.num_conts = 0; @@ -642,12 +637,11 @@ BOOL T1_download_glyph(PHYSDEV dev, DOWNLOAD *pdl, DWORD index, char *glyph_name } str_add_cmd(charstring, endchar);
- HeapFree(GetProcessHeap(), 0, outline.pts); - HeapFree(GetProcessHeap(), 0, outline.end_pts); - HeapFree(GetProcessHeap(), 0, outline.flags); + free(outline.pts); + free(outline.end_pts); + free(outline.flags);
- buf = HeapAlloc(GetProcessHeap(), 0, sizeof(glyph_def_begin) + - strlen(pdl->ps_name) + strlen(glyph_name) + 100); + buf = malloc(sizeof(glyph_def_begin) + strlen(pdl->ps_name) + strlen(glyph_name) + 100);
sprintf(buf, "%%%%glyph %04lx\n", index); PSDRV_WriteSpool(dev, buf, strlen(buf)); @@ -661,13 +655,13 @@ BOOL T1_download_glyph(PHYSDEV dev, DOWNLOAD *pdl, DWORD index, char *glyph_name str_free(charstring);
t1->glyph_sent[index] = TRUE; - HeapFree(GetProcessHeap(), 0, buf); + free(buf); return TRUE; }
void T1_free(TYPE1 *t1) { - HeapFree(GetProcessHeap(), 0, t1->glyph_sent); - HeapFree(GetProcessHeap(), 0, t1); + free(t1->glyph_sent); + free(t1); return; } diff --git a/dlls/wineps.drv/type1afm.c b/dlls/wineps.drv/type1afm.c index c78753393c0..2438235cd17 100644 --- a/dlls/wineps.drv/type1afm.c +++ b/dlls/wineps.drv/type1afm.c @@ -1126,7 +1126,7 @@ static BOOL ReadAFMDir(LPCSTR dirname) BOOL ret = TRUE;
if (!path) return TRUE; - if (!(filename = HeapAlloc( GetProcessHeap(), 0, lstrlenW(path) + 256 ))) + if (!(filename = malloc( wcslen(path) + 256 ))) { HeapFree( GetProcessHeap(), 0, path ); return FALSE; @@ -1150,7 +1150,7 @@ static BOOL ReadAFMDir(LPCSTR dirname) } _findclose( handle );
- HeapFree( GetProcessHeap(), 0, filename ); + free( filename ); return ret; }
diff --git a/dlls/wineps.drv/type42.c b/dlls/wineps.drv/type42.c index 13b5c627e38..868bf87d5dc 100644 --- a/dlls/wineps.drv/type42.c +++ b/dlls/wineps.drv/type42.c @@ -103,7 +103,7 @@ static BOOL LoadTable(HDC hdc, OTTable *table) table->len = 0; len = GetFontData(hdc, table->MS_tag, 0, NULL, 0); if(len == GDI_ERROR) return FALSE; - table->data = HeapAlloc(GetProcessHeap(), 0, (len + 3) & ~3); + table->data = malloc((len + 3) & ~3); if(!table->data) return FALSE; table->len = len; memset(table->data + ((table->len - 1) & ~3), 0, sizeof(DWORD)); @@ -168,7 +168,7 @@ TYPE42 *T42_download_header(PHYSDEV dev, char *ps_name, "currentdict end dup /FontName get exch definefont pop\n";
- t42 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*t42)); + t42 = calloc(1, sizeof(*t42)); memcpy(t42->tables, tables_templ, sizeof(tables_templ)); t42->loca_tab = t42->glyf_tab = t42->head_tab = t42->hmtx_tab = -1; t42->emsize = emsize; @@ -196,12 +196,9 @@ TYPE42 *T42_download_header(PHYSDEV dev, char *ps_name, }
t42->glyph_sent_size = GLYPH_SENT_INC; - t42->glyph_sent = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - t42->glyph_sent_size * - sizeof(*(t42->glyph_sent))); + t42->glyph_sent = calloc(t42->glyph_sent_size, sizeof(*(t42->glyph_sent)));
- buf = HeapAlloc(GetProcessHeap(), 0, sizeof(start) + strlen(ps_name) + - 100); + buf = malloc(sizeof(start) + strlen(ps_name) + 100);
push_lc_numeric("C"); sprintf(buf, start, ps_name, @@ -250,15 +247,14 @@ TYPE42 *T42_download_header(PHYSDEV dev, char *ps_name, /* glyf_blocks is a 0 terminated list, holding the start offset of each block. For simplicity glyf_blocks[0] is 0 */ nb_blocks = 2; - t42->glyf_blocks = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (nb_blocks + 1) * sizeof(DWORD)); + t42->glyf_blocks = calloc(nb_blocks + 1, sizeof(DWORD)); for(i = 0; i < GET_BE_WORD(t42->tables[t42->maxp_tab].data + 4); i++) { DWORD start, end, size; get_glyf_pos(t42, i, &start, &end); size = end - t42->glyf_blocks[nb_blocks-2]; if(size > 0x2000 && t42->glyf_blocks[nb_blocks-1] % 4 == 0) { nb_blocks++; - t42->glyf_blocks = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - t42->glyf_blocks, (nb_blocks + 1) * sizeof(DWORD)); + t42->glyf_blocks = _recalloc(t42->glyf_blocks, nb_blocks + 1, sizeof(DWORD)); } t42->glyf_blocks[nb_blocks-1] = end; } @@ -274,7 +270,7 @@ TYPE42 *T42_download_header(PHYSDEV dev, char *ps_name, PSDRV_WriteSpool(dev, storage, sizeof(storage) - 1); sprintf(buf, end, loca_off, glyf_off); PSDRV_WriteSpool(dev, buf, strlen(buf)); - HeapFree(GetProcessHeap(), 0, buf); + free(buf); return t42; }
@@ -309,9 +305,7 @@ BOOL T42_download_glyph(PHYSDEV dev, DOWNLOAD *pdl, DWORD index, return TRUE; } else { t42->glyph_sent_size = (index / GLYPH_SENT_INC + 1) * GLYPH_SENT_INC; - t42->glyph_sent = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - t42->glyph_sent, - t42->glyph_sent_size * sizeof(*(t42->glyph_sent))); + t42->glyph_sent = _recalloc(t42->glyph_sent, t42->glyph_sent_size, sizeof(*(t42->glyph_sent))); }
if(!get_glyf_pos(t42, index, &start, &end)) return FALSE; @@ -347,8 +341,7 @@ BOOL T42_download_glyph(PHYSDEV dev, DOWNLOAD *pdl, DWORD index, for(i = 1; t42->glyf_blocks[i]; i++) if(start < t42->glyf_blocks[i]) break;
- buf = HeapAlloc(GetProcessHeap(), 0, sizeof(glyph_def) + - strlen(pdl->ps_name) + 100); + buf = malloc(sizeof(glyph_def) + strlen(pdl->ps_name) + 100);
/* we don't have a string for the gdir and glyf tables, but we do have a string for the TT header. So the offset we need is tables - 2 */ @@ -367,7 +360,7 @@ BOOL T42_download_glyph(PHYSDEV dev, DOWNLOAD *pdl, DWORD index, PSDRV_WriteSpool(dev, buf, strlen(buf));
t42->glyph_sent[index] = TRUE; - HeapFree(GetProcessHeap(), 0, buf); + free(buf); return TRUE; }
@@ -375,9 +368,9 @@ void T42_free(TYPE42 *t42) { OTTable *table; for(table = t42->tables; table->MS_tag; table++) - HeapFree(GetProcessHeap(), 0, table->data); - HeapFree(GetProcessHeap(), 0, t42->glyph_sent); - HeapFree(GetProcessHeap(), 0, t42->glyf_blocks); - HeapFree(GetProcessHeap(), 0, t42); + free(table->data); + free(t42->glyph_sent); + free(t42->glyf_blocks); + free(t42); return; }