diff --git a/dlls/gdi32/bitblt.c b/dlls/gdi32/bitblt.c index c9486cb8961..d7bbd353b2d 100644 --- a/dlls/gdi32/bitblt.c +++ b/dlls/gdi32/bitblt.c @@ -165,7 +165,7 @@ static BOOL get_vis_rectangles( DC *dc_dst, struct bitblt_coords *dst, void CDECL free_heap_bits( struct gdi_image_bits *bits ) { - HeapFree( GetProcessHeap(), 0, bits->ptr ); + free( bits->ptr ); } DWORD convert_bits( const BITMAPINFO *src_info, struct bitblt_coords *src, @@ -180,7 +180,7 @@ DWORD convert_bits( const BITMAPINFO *src_info, struct bitblt_coords *src, dst_info->bmiHeader.biSizeImage = get_dib_image_size( dst_info ); if (top_down) dst_info->bmiHeader.biHeight = -dst_info->bmiHeader.biHeight; - if (!(ptr = HeapAlloc( GetProcessHeap(), 0, dst_info->bmiHeader.biSizeImage ))) + if (!(ptr = malloc( dst_info->bmiHeader.biSizeImage ))) return ERROR_OUTOFMEMORY; err = convert_bitmapinfo( src_info, bits->ptr, src, dst_info, ptr ); @@ -203,7 +203,7 @@ DWORD stretch_bits( const BITMAPINFO *src_info, struct bitblt_coords *src, dst_info->bmiHeader.biSizeImage = get_dib_image_size( dst_info ); if (src_info->bmiHeader.biHeight < 0) dst_info->bmiHeader.biHeight = -dst_info->bmiHeader.biHeight; - if (!(ptr = HeapAlloc( GetProcessHeap(), 0, dst_info->bmiHeader.biSizeImage ))) + if (!(ptr = malloc( dst_info->bmiHeader.biSizeImage ))) return ERROR_OUTOFMEMORY; err = stretch_bitmapinfo( src_info, bits->ptr, src, dst_info, ptr, dst, mode ); @@ -221,7 +221,7 @@ static DWORD blend_bits( const BITMAPINFO *src_info, const struct gdi_image_bits if (!dst_bits->is_copy) { int size = dst_info->bmiHeader.biSizeImage; - void *ptr = HeapAlloc( GetProcessHeap(), 0, size ); + void *ptr = malloc( size ); if (!ptr) return ERROR_OUTOFMEMORY; memcpy( ptr, dst_bits->ptr, size ); if (dst_bits->free) dst_bits->free( dst_bits ); @@ -428,7 +428,7 @@ BOOL CDECL nulldrv_GradientFill( PHYSDEV dev, TRIVERTEX *vert_array, ULONG nvert DWORD err; HRGN rgn; - if (!(pts = HeapAlloc( GetProcessHeap(), 0, nvert * sizeof(*pts) ))) return FALSE; + if (!(pts = malloc( nvert * sizeof(*pts) ))) return FALSE; for (i = 0; i < nvert; i++) { pts[i].x = vert_array[i].x; @@ -470,7 +470,7 @@ BOOL CDECL nulldrv_GradientFill( PHYSDEV dev, TRIVERTEX *vert_array, ULONG nvert if (err && err != ERROR_BAD_FORMAT) goto done; info->bmiHeader.biSizeImage = get_dib_image_size( info ); - if (!(bits.ptr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, info->bmiHeader.biSizeImage ))) + if (!(bits.ptr = calloc( 1, info->bmiHeader.biSizeImage ))) goto done; bits.is_copy = TRUE; bits.free = free_heap_bits; @@ -495,7 +495,7 @@ BOOL CDECL nulldrv_GradientFill( PHYSDEV dev, TRIVERTEX *vert_array, ULONG nvert NtGdiDeleteObjectApp( rgn ); done: - HeapFree( GetProcessHeap(), 0, pts ); + free( pts ); return ret; } diff --git a/dlls/gdi32/bitmap.c b/dlls/gdi32/bitmap.c index c0c4cd97611..00c8b347af5 100644 --- a/dlls/gdi32/bitmap.c +++ b/dlls/gdi32/bitmap.c @@ -147,7 +147,7 @@ HBITMAP WINAPI NtGdiCreateBitmap( INT width, INT height, UINT planes, } /* Create the BITMAPOBJ */ - if (!(bmpobj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*bmpobj) ))) + if (!(bmpobj = calloc( 1, sizeof(*bmpobj) ))) { SetLastError( ERROR_NOT_ENOUGH_MEMORY ); return 0; @@ -159,18 +159,18 @@ HBITMAP WINAPI NtGdiCreateBitmap( INT width, INT height, UINT planes, bmpobj->dib.dsBm.bmWidthBytes = get_bitmap_stride( width, bpp ); bmpobj->dib.dsBm.bmPlanes = planes; bmpobj->dib.dsBm.bmBitsPixel = bpp; - bmpobj->dib.dsBm.bmBits = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size ); + bmpobj->dib.dsBm.bmBits = calloc( 1, size ); if (!bmpobj->dib.dsBm.bmBits) { - HeapFree( GetProcessHeap(), 0, bmpobj ); + free( bmpobj ); SetLastError( ERROR_NOT_ENOUGH_MEMORY ); return 0; } if (!(hbitmap = alloc_gdi_handle( &bmpobj->obj, NTGDI_OBJ_BITMAP, &bitmap_funcs ))) { - HeapFree( GetProcessHeap(), 0, bmpobj->dib.dsBm.bmBits ); - HeapFree( GetProcessHeap(), 0, bmpobj ); + free( bmpobj->dib.dsBm.bmBits ); + free( bmpobj ); return 0; } @@ -322,7 +322,7 @@ LONG WINAPI NtGdiSetBitmapBits( } else { - if (!(src_bits.ptr = HeapAlloc( GetProcessHeap(), 0, dst.height * dst_stride ))) + if (!(src_bits.ptr = malloc( dst.height * dst_stride ))) { GDI_ReleaseObj( hbitmap ); return 0; @@ -444,8 +444,8 @@ static BOOL BITMAP_DeleteObject( HGDIOBJ handle ) BITMAPOBJ *bmp = free_gdi_handle( handle ); if (!bmp) return FALSE; - HeapFree( GetProcessHeap(), 0, bmp->dib.dsBm.bmBits ); - HeapFree( GetProcessHeap(), 0, bmp ); + free( bmp->dib.dsBm.bmBits ); + free( bmp ); return TRUE; } diff --git a/dlls/gdi32/brush.c b/dlls/gdi32/brush.c index 5b92e6e5368..5a218980f31 100644 --- a/dlls/gdi32/brush.c +++ b/dlls/gdi32/brush.c @@ -73,12 +73,12 @@ static BOOL copy_bitmap( struct brush_pattern *brush, HBITMAP bitmap ) brush->bits = bits; if (!bits.free) { - if (!(brush->bits.ptr = HeapAlloc( GetProcessHeap(), 0, info->bmiHeader.biSizeImage ))) goto done; + if (!(brush->bits.ptr = malloc( info->bmiHeader.biSizeImage ))) goto done; memcpy( brush->bits.ptr, bits.ptr, info->bmiHeader.biSizeImage ); brush->bits.free = free_heap_bits; } - if (!(brush->info = HeapAlloc( GetProcessHeap(), 0, get_dib_info_size( info, DIB_RGB_COLORS )))) + if (!(brush->info = malloc( get_dib_info_size( info, DIB_RGB_COLORS )))) { if (brush->bits.free) brush->bits.free( &brush->bits ); goto done; @@ -141,7 +141,7 @@ BOOL store_brush_pattern( LOGBRUSH *brush, struct brush_pattern *pattern ) void free_brush_pattern( struct brush_pattern *pattern ) { if (pattern->bits.free) pattern->bits.free( &pattern->bits ); - HeapFree( GetProcessHeap(), 0, pattern->info ); + free( pattern->info ); } BOOL CDECL get_brush_bitmap_info( HBRUSH handle, BITMAPINFO *info, void *bits, UINT *usage ) @@ -193,7 +193,7 @@ HBRUSH create_brush( const LOGBRUSH *brush ) BRUSHOBJ * ptr; HBRUSH hbrush; - if (!(ptr = HeapAlloc( GetProcessHeap(), 0, sizeof(*ptr) ))) return 0; + if (!(ptr = malloc( sizeof(*ptr) ))) return 0; ptr->logbrush = *brush; @@ -205,7 +205,7 @@ HBRUSH create_brush( const LOGBRUSH *brush ) } free_brush_pattern( &ptr->pattern ); - HeapFree( GetProcessHeap(), 0, ptr ); + free( ptr ); return 0; } @@ -335,7 +335,7 @@ static BOOL BRUSH_DeleteObject( HGDIOBJ handle ) if (!brush) return FALSE; free_brush_pattern( &brush->pattern ); - HeapFree( GetProcessHeap(), 0, brush ); + free( brush ); return TRUE; } diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c index 541081cb856..c00e5128ced 100644 --- a/dlls/gdi32/dc.c +++ b/dlls/gdi32/dc.c @@ -132,10 +132,10 @@ DC *alloc_dc_ptr( DWORD magic ) { DC *dc; - if (!(dc = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*dc) ))) return NULL; - if (!(dc->attr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*dc->attr)))) + if (!(dc = calloc( 1, sizeof(*dc) ))) return NULL; + if (!(dc->attr = RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*dc->attr) ))) { - HeapFree( GetProcessHeap(), 0, dc ); + free( dc ); return NULL; } @@ -152,8 +152,8 @@ DC *alloc_dc_ptr( DWORD magic ) if (!(dc->hSelf = alloc_gdi_handle( &dc->obj, magic, &dc_funcs ))) { - HeapFree( GetProcessHeap(), 0, dc->attr ); - HeapFree( GetProcessHeap(), 0, dc ); + RtlFreeHeap( GetProcessHeap(), 0, dc->attr ); + free( dc ); return NULL; } dc->attr->hdc = dc->nulldrv.hdc = dc->hSelf; @@ -179,8 +179,8 @@ static void free_dc_state( DC *dc ) if (dc->hVisRgn) NtGdiDeleteObjectApp( dc->hVisRgn ); if (dc->region) NtGdiDeleteObjectApp( dc->region ); if (dc->path) free_gdi_path( dc->path ); - HeapFree( GetProcessHeap(), 0, dc->attr ); - HeapFree( GetProcessHeap(), 0, dc ); + RtlFreeHeap( GetProcessHeap(), 0, dc->attr ); + free( dc ); } @@ -472,14 +472,14 @@ INT WINAPI NtGdiSaveDC( HDC hdc ) if (!(dc = get_dc_ptr( hdc ))) return 0; - if (!(newdc = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*newdc )))) + if (!(newdc = calloc( 1, sizeof(*newdc )))) { release_dc_ptr( dc ); return 0; } - if (!(newdc->attr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*newdc->attr) ))) + if (!(newdc->attr = calloc( 1, sizeof(*newdc->attr) ))) { - HeapFree( GetProcessHeap(), 0, newdc ); + free( newdc ); release_dc_ptr( dc ); return 0; } diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c index a8361235c77..b27b341d470 100644 --- a/dlls/gdi32/dib.c +++ b/dlls/gdi32/dib.c @@ -329,7 +329,7 @@ static BOOL build_rle_bitmap( BITMAPINFO *info, struct gdi_image_bits *bits, HRG assert( info->bmiHeader.biBitCount == 4 || info->bmiHeader.biBitCount == 8 ); - out_bits = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, get_dib_image_size( info ) ); + out_bits = calloc( 1, get_dib_image_size( info ) ); if (!out_bits) goto fail; if (clip) @@ -456,7 +456,7 @@ done: fail: if (run) NtGdiDeleteObjectApp( run ); if (clip && *clip) NtGdiDeleteObjectApp( *clip ); - HeapFree( GetProcessHeap(), 0, out_bits ); + free( out_bits ); return FALSE; } @@ -1185,7 +1185,7 @@ BITMAPINFO *copy_packed_dib( const BITMAPINFO *src_info, UINT usage ) if (!bitmapinfo_from_user_bitmapinfo( info, src_info, usage, FALSE )) return NULL; info_size = get_dib_info_size( info, usage ); - if ((ret = HeapAlloc( GetProcessHeap(), 0, info_size + info->bmiHeader.biSizeImage ))) + if ((ret = malloc( info_size + info->bmiHeader.biSizeImage ))) { memcpy( ret, info, info_size ); memcpy( (char *)ret + info_size, (char *)src_info + bitmap_info_size( src_info, usage ), @@ -1486,7 +1486,7 @@ HBITMAP WINAPI NtGdiCreateDIBSection( HDC hdc, HANDLE section, DWORD offset, con WARN( "%u planes not properly supported\n", info->bmiHeader.biPlanes ); } - if (!(bmp = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*bmp) ))) return 0; + if (!(bmp = calloc( 1, sizeof(*bmp) ))) return 0; TRACE("format (%d,%d), planes %d, bpp %d, %s, size %d %s\n", info->bmiHeader.biWidth, info->bmiHeader.biHeight, @@ -1507,8 +1507,7 @@ HBITMAP WINAPI NtGdiCreateDIBSection( HDC hdc, HANDLE section, DWORD offset, con if (usage == DIB_PAL_COLORS && !fill_color_table_from_pal_colors( info, hdc )) goto error; bmp->dib.dsBmih.biClrUsed = info->bmiHeader.biClrUsed; - if (!(bmp->color_table = HeapAlloc( GetProcessHeap(), 0, - bmp->dib.dsBmih.biClrUsed * sizeof(RGBQUAD) ))) + if (!(bmp->color_table = malloc( bmp->dib.dsBmih.biClrUsed * sizeof(RGBQUAD) ))) goto error; memcpy( bmp->color_table, info->bmiColors, bmp->dib.dsBmih.biClrUsed * sizeof(RGBQUAD) ); } @@ -1569,8 +1568,8 @@ HBITMAP WINAPI NtGdiCreateDIBSection( HDC hdc, HANDLE section, DWORD offset, con NtFreeVirtualMemory( GetCurrentProcess(), &bmp->dib.dsBm.bmBits, &size, MEM_RELEASE ); } error: - HeapFree( GetProcessHeap(), 0, bmp->color_table ); - HeapFree( GetProcessHeap(), 0, bmp ); + free( bmp->color_table ); + free( bmp ); return 0; } @@ -1631,7 +1630,7 @@ NTSTATUS WINAPI NtGdiDdDDICreateDCFromMemory( D3DKMT_CREATEDCFROMMEMORY *desc ) if (!desc->hDeviceDc || !(dc = NtGdiCreateCompatibleDC( desc->hDeviceDc ))) return STATUS_INVALID_PARAMETER; - if (!(bmp = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*bmp) ))) goto error; + if (!(bmp = calloc( 1, sizeof(*bmp) ))) goto error; bmp->dib.dsBm.bmWidth = desc->Width; bmp->dib.dsBm.bmHeight = desc->Height; @@ -1655,7 +1654,7 @@ NTSTATUS WINAPI NtGdiDdDDICreateDCFromMemory( D3DKMT_CREATEDCFROMMEMORY *desc ) if (format->palette_size) { - if (!(bmp->color_table = HeapAlloc( GetProcessHeap(), 0, format->palette_size * sizeof(*bmp->color_table) ))) + if (!(bmp->color_table = malloc( format->palette_size * sizeof(*bmp->color_table) ))) goto error; if (desc->pColorTable) { @@ -1682,8 +1681,8 @@ NTSTATUS WINAPI NtGdiDdDDICreateDCFromMemory( D3DKMT_CREATEDCFROMMEMORY *desc ) return STATUS_SUCCESS; error: - if (bmp) HeapFree( GetProcessHeap(), 0, bmp->color_table ); - HeapFree( GetProcessHeap(), 0, bmp ); + if (bmp) free( bmp->color_table ); + free( bmp ); NtGdiDeleteObjectApp( dc ); return STATUS_INVALID_PARAMETER; } @@ -1759,7 +1758,7 @@ static BOOL DIB_DeleteObject( HGDIOBJ handle ) NtFreeVirtualMemory( GetCurrentProcess(), &bmp->dib.dsBm.bmBits, &size, MEM_RELEASE ); } - HeapFree(GetProcessHeap(), 0, bmp->color_table); - HeapFree( GetProcessHeap(), 0, bmp ); + free( bmp->color_table ); + free( bmp ); return TRUE; } diff --git a/dlls/gdi32/dibdrv/bitblt.c b/dlls/gdi32/dibdrv/bitblt.c index 0218cd0eea5..76330679e59 100644 --- a/dlls/gdi32/dibdrv/bitblt.c +++ b/dlls/gdi32/dibdrv/bitblt.c @@ -699,7 +699,7 @@ static DWORD copy_src_bits( dib_info *src, RECT *src_rect ) { int y, stride = get_dib_stride( src->width, src->bit_count ); int height = src_rect->bottom - src_rect->top; - void *ptr = HeapAlloc( GetProcessHeap(), 0, stride * height ); + void *ptr = malloc( stride * height ); if (!ptr) return ERROR_OUTOFMEMORY; @@ -730,7 +730,7 @@ static DWORD create_tmp_dib( const dib_info *copy, int width, int height, dib_in ret->rect.top = 0; ret->rect.right = width; ret->rect.bottom = height; - ret->bits.ptr = HeapAlloc( GetProcessHeap(), 0, ret->height * ret->stride ); + ret->bits.ptr = malloc( ret->height * ret->stride ); ret->bits.is_copy = TRUE; ret->bits.free = free_heap_bits; ret->bits.param = NULL; @@ -1442,7 +1442,7 @@ BOOL CDECL dibdrv_GradientFill( PHYSDEV dev, TRIVERTEX *vert_array, ULONG nvert, RECT bounds; BOOL ret = TRUE; - if (!(pts = HeapAlloc( GetProcessHeap(), 0, nvert * sizeof(*pts) ))) return FALSE; + if (!(pts = malloc( nvert * sizeof(*pts) ))) return FALSE; for (i = 0; i < nvert; i++) { pts[i].x = vert_array[i].x; @@ -1489,6 +1489,6 @@ BOOL CDECL dibdrv_GradientFill( PHYSDEV dev, TRIVERTEX *vert_array, ULONG nvert, break; } - HeapFree( GetProcessHeap(), 0, pts ); + free( pts ); return ret; } diff --git a/dlls/gdi32/dibdrv/dc.c b/dlls/gdi32/dibdrv/dc.c index 93f1ad8310c..0512307531d 100644 --- a/dlls/gdi32/dibdrv/dc.c +++ b/dlls/gdi32/dibdrv/dc.c @@ -291,7 +291,7 @@ int get_clipped_rects( const dib_info *dib, const RECT *rc, HRGN clip, struct cl out++; if (out == &clip_rects->buffer[ARRAY_SIZE( clip_rects->buffer )]) { - clip_rects->rects = HeapAlloc( GetProcessHeap(), 0, region->numRects * sizeof(RECT) ); + clip_rects->rects = malloc( region->numRects * sizeof(RECT) ); if (!clip_rects->rects) return 0; memcpy( clip_rects->rects, clip_rects->buffer, (out - clip_rects->buffer) * sizeof(RECT) ); out = clip_rects->rects + (out - clip_rects->buffer); @@ -328,7 +328,7 @@ void add_clipped_bounds( dibdrv_physdev *dev, const RECT *rect, HRGN clip ) static BOOL CDECL dibdrv_CreateDC( PHYSDEV *dev, LPCWSTR device, LPCWSTR output, const DEVMODEW *data ) { - dibdrv_physdev *pdev = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pdev) ); + dibdrv_physdev *pdev = calloc( 1, sizeof(*pdev) ); if (!pdev) return FALSE; clear_dib_info(&pdev->dib); @@ -348,7 +348,7 @@ static BOOL CDECL dibdrv_DeleteDC( PHYSDEV dev ) free_pattern_brush( &pdev->brush ); free_pattern_brush( &pdev->pen_brush ); release_cached_font( pdev->font ); - HeapFree( GetProcessHeap(), 0, pdev ); + free( pdev ); return TRUE; } @@ -875,13 +875,13 @@ static BOOL CDECL windrv_Chord( PHYSDEV dev, INT left, INT top, INT right, INT b static BOOL CDECL windrv_CreateDC( PHYSDEV *dev, LPCWSTR device, LPCWSTR output, const DEVMODEW *devmode ) { - struct windrv_physdev *physdev = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*physdev) ); + struct windrv_physdev *physdev = calloc( 1, sizeof(*physdev) ); if (!physdev) return FALSE; if (!dib_driver.pCreateDC( dev, NULL, NULL, NULL )) { - HeapFree( GetProcessHeap(), 0, physdev ); + free( physdev ); return FALSE; } physdev->dibdrv = get_dibdrv_pdev( *dev ); @@ -894,7 +894,7 @@ static BOOL CDECL windrv_DeleteDC( PHYSDEV dev ) struct windrv_physdev *physdev = get_windrv_physdev( dev ); window_surface_release( physdev->surface ); - HeapFree( GetProcessHeap(), 0, physdev ); + free( physdev ); return TRUE; } diff --git a/dlls/gdi32/dibdrv/dibdrv.h b/dlls/gdi32/dibdrv/dibdrv.h index 71f6456bac3..d5606388e30 100644 --- a/dlls/gdi32/dibdrv/dibdrv.h +++ b/dlls/gdi32/dibdrv/dibdrv.h @@ -273,7 +273,7 @@ static inline void init_clipped_rects( struct clipped_rects *clip_rects ) static inline void free_clipped_rects( struct clipped_rects *clip_rects ) { - if (clip_rects->rects != clip_rects->buffer) HeapFree( GetProcessHeap(), 0, clip_rects->rects ); + if (clip_rects->rects != clip_rects->buffer) free( clip_rects->rects ); } /* compute the x coordinate corresponding to y on the specified edge */ diff --git a/dlls/gdi32/dibdrv/graphics.c b/dlls/gdi32/dibdrv/graphics.c index 3d9901b798f..875ae308546 100644 --- a/dlls/gdi32/dibdrv/graphics.c +++ b/dlls/gdi32/dibdrv/graphics.c @@ -344,7 +344,7 @@ static BOOL draw_arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom, pt[1].x -= rect.left + width / 2; pt[1].y -= rect.top + height / 2; - points = HeapAlloc( GetProcessHeap(), 0, (width + height) * 3 * sizeof(*points) ); + points = malloc( (width + height) * 3 * sizeof(*points) ); if (!points) return FALSE; if (extra_lines == -1) @@ -363,13 +363,13 @@ static BOOL draw_arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom, } if (count < 2) { - HeapFree( GetProcessHeap(), 0, points ); + free( points ); return TRUE; } if (pdev->pen_uses_region && !(outline = NtGdiCreateRectRgn( 0, 0, 0, 0 ))) { - HeapFree( GetProcessHeap(), 0, points ); + free( points ); return FALSE; } @@ -378,7 +378,7 @@ static BOOL draw_arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom, get_dib_rect( &pdev->dib, &rc ) && !(interior = create_polypolygon_region( points, &count, 1, WINDING, &rc ))) { - HeapFree( GetProcessHeap(), 0, points ); + free( points ); if (outline) NtGdiDeleteObjectApp( outline ); return FALSE; } @@ -406,7 +406,7 @@ static BOOL draw_arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom, if (ret) ret = pen_region( pdev, outline ); NtGdiDeleteObjectApp( outline ); } - HeapFree( GetProcessHeap(), 0, points ); + free( points ); return ret; } @@ -600,13 +600,13 @@ static struct cached_font *add_cached_font( DC *dc, HFONT hfont, UINT aa_flags ) { if (!ptr->glyphs[i][j]) continue; for (k = 0; k < GLYPH_CACHE_PAGE_SIZE; k++) - HeapFree( GetProcessHeap(), 0, ptr->glyphs[i][j][k] ); - HeapFree( GetProcessHeap(), 0, ptr->glyphs[i][j] ); + free( ptr->glyphs[i][j][k] ); + free( ptr->glyphs[i][j] ); } } list_remove( &ptr->entry ); } - else if (!(ptr = HeapAlloc( GetProcessHeap(), 0, sizeof(*ptr) ))) + else if (!(ptr = malloc( sizeof(*ptr) ))) { LeaveCriticalSection( &font_cache_cs ); return NULL; @@ -639,18 +639,18 @@ static struct cached_glyph *add_cached_glyph( struct cached_font *font, UINT ind { struct cached_glyph **ptr; - ptr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, GLYPH_CACHE_PAGE_SIZE * sizeof(*ptr) ); + ptr = calloc( 1, GLYPH_CACHE_PAGE_SIZE * sizeof(*ptr) ); if (!ptr) { - HeapFree( GetProcessHeap(), 0, glyph ); + free( glyph ); return NULL; } if (InterlockedCompareExchangePointer( (void **)&font->glyphs[type][page], ptr, NULL )) - HeapFree( GetProcessHeap(), 0, ptr ); + free( ptr ); } ret = InterlockedCompareExchangePointer( (void **)&font->glyphs[type][page][entry], glyph, NULL ); if (!ret) ret = glyph; - else HeapFree( GetProcessHeap(), 0, glyph ); + else free( glyph ); return ret; } @@ -775,7 +775,7 @@ static struct cached_glyph *cache_glyph_bitmap( DC *dc, struct cached_font *font bit_count = get_glyph_depth( font->aa_flags ); stride = get_dib_stride( metrics.gmBlackBoxX, bit_count ); size = metrics.gmBlackBoxY * stride; - glyph = HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET( struct cached_glyph, bits[size] )); + glyph = malloc( FIELD_OFFSET( struct cached_glyph, bits[size] )); if (!glyph) return NULL; if (!size) goto done; /* empty glyph */ @@ -785,7 +785,7 @@ static struct cached_glyph *cache_glyph_bitmap( DC *dc, struct cached_font *font &identity, FALSE ); if (ret == GDI_ERROR) { - HeapFree( GetProcessHeap(), 0, glyph ); + free( glyph ); return NULL; } assert( ret <= size ); @@ -1269,7 +1269,7 @@ BOOL CDECL dibdrv_PolyPolygon( PHYSDEV dev, const POINT *pt, const INT *counts, if (total > ARRAY_SIZE( pt_buf )) { - points = HeapAlloc( GetProcessHeap(), 0, total * sizeof(*pt) ); + points = malloc( total * sizeof(*pt) ); if (!points) return FALSE; } memcpy( points, pt, total * sizeof(*pt) ); @@ -1315,7 +1315,7 @@ BOOL CDECL dibdrv_PolyPolygon( PHYSDEV dev, const POINT *pt, const INT *counts, } done: - if (points != pt_buf) HeapFree( GetProcessHeap(), 0, points ); + if (points != pt_buf) free( points ); return ret; } @@ -1340,7 +1340,7 @@ BOOL CDECL dibdrv_PolyPolyline( PHYSDEV dev, const POINT* pt, const DWORD* count if (total > ARRAY_SIZE( pt_buf )) { - points = HeapAlloc( GetProcessHeap(), 0, total * sizeof(*pt) ); + points = malloc( total * sizeof(*pt) ); if (!points) return FALSE; } memcpy( points, pt, total * sizeof(*pt) ); @@ -1367,7 +1367,7 @@ BOOL CDECL dibdrv_PolyPolyline( PHYSDEV dev, const POINT* pt, const DWORD* count } done: - if (points != pt_buf) HeapFree( GetProcessHeap(), 0, points ); + if (points != pt_buf) free( points ); return ret; } @@ -1472,12 +1472,12 @@ BOOL CDECL dibdrv_RoundRect( PHYSDEV dev, INT left, INT top, INT right, INT bott if (ellipse_width <= 2|| ellipse_height <= 2) return dibdrv_Rectangle( dev, left, top, right, bottom ); - points = HeapAlloc( GetProcessHeap(), 0, (ellipse_width + ellipse_height) * 2 * sizeof(*points) ); + points = malloc( (ellipse_width + ellipse_height) * 2 * sizeof(*points) ); if (!points) return FALSE; if (pdev->pen_uses_region && !(outline = NtGdiCreateRectRgn( 0, 0, 0, 0 ))) { - HeapFree( GetProcessHeap(), 0, points ); + free( points ); return FALSE; } @@ -1485,7 +1485,7 @@ BOOL CDECL dibdrv_RoundRect( PHYSDEV dev, INT left, INT top, INT right, INT bott !(interior = NtGdiCreateRoundRectRgn( rect.left, rect.top, rect.right + 1, rect.bottom + 1, ellipse_width, ellipse_height ))) { - HeapFree( GetProcessHeap(), 0, points ); + free( points ); if (outline) NtGdiDeleteObjectApp( outline ); return FALSE; } @@ -1556,7 +1556,7 @@ BOOL CDECL dibdrv_RoundRect( PHYSDEV dev, INT left, INT top, INT right, INT bott if (ret) ret = pen_region( pdev, outline ); NtGdiDeleteObjectApp( outline ); } - HeapFree( GetProcessHeap(), 0, points ); + free( points ); return ret; } diff --git a/dlls/gdi32/dibdrv/objects.c b/dlls/gdi32/dibdrv/objects.c index eff39848755..d137daa1f33 100644 --- a/dlls/gdi32/dibdrv/objects.c +++ b/dlls/gdi32/dibdrv/objects.c @@ -1821,14 +1821,14 @@ static BOOL alloc_brush_mask_bits( dib_brush *brush ) assert(brush->masks.xor == NULL); assert(brush->dib.stride > 0); - if (!(brush->masks.xor = HeapAlloc(GetProcessHeap(), 0, 2 * size))) return FALSE; + if (!(brush->masks.xor = malloc( 2 * size ))) return FALSE; brush->masks.and = (char *)brush->masks.xor + size; return TRUE; } static void free_brush_mask_bits( dib_brush *brush ) { - if (brush->masks.xor != brush->dib.bits.ptr) HeapFree(GetProcessHeap(), 0, brush->masks.xor); + if (brush->masks.xor != brush->dib.bits.ptr) free( brush->masks.xor ); brush->masks.and = brush->masks.xor = NULL; } @@ -2022,7 +2022,7 @@ static BOOL select_pattern_brush( dibdrv_physdev *pdev, dib_brush *brush, BOOL * } else { - brush->dib.bits.ptr = HeapAlloc( GetProcessHeap(), 0, brush->dib.height * brush->dib.stride ); + brush->dib.bits.ptr = malloc( brush->dib.height * brush->dib.stride ); brush->dib.bits.is_copy = TRUE; brush->dib.bits.free = free_heap_bits; brush->dib.funcs->convert_to(&brush->dib, &pattern, &pattern.rect, dither); @@ -2173,7 +2173,7 @@ HPEN CDECL dibdrv_SelectPen( PHYSDEV dev, HPEN hpen, const struct brush_pattern if (!size) return 0; - elp = HeapAlloc( GetProcessHeap(), 0, size ); + elp = malloc( size ); NtGdiExtGetObjectW( hpen, size, elp ); logpen.lopnStyle = elp->elpPenStyle; @@ -2253,7 +2253,7 @@ HPEN CDECL dibdrv_SelectPen( PHYSDEV dev, HPEN hpen, const struct brush_pattern pdev->pen_uses_region = (logpen.lopnStyle & PS_GEOMETRIC || pdev->pen_width > 1); pdev->pen_is_ext = (elp != NULL); - HeapFree( GetProcessHeap(), 0, elp ); + free( elp ); return hpen; } diff --git a/dlls/gdi32/dibdrv/opengl.c b/dlls/gdi32/dibdrv/opengl.c index 25688889ce8..9261cc09299 100644 --- a/dlls/gdi32/dibdrv/opengl.c +++ b/dlls/gdi32/dibdrv/opengl.c @@ -148,12 +148,12 @@ static struct wgl_context * CDECL osmesa_create_context( HDC hdc, const PIXELFOR default: return NULL; } - if (!(context = RtlAllocateHeap( GetProcessHeap(), 0, sizeof( *context )))) return NULL; + if (!(context = malloc( sizeof( *context )))) return NULL; context->format = gl_format; if (!(context->context = pOSMesaCreateContextExt( gl_format, descr->cDepthBits, descr->cStencilBits, descr->cAccumBits, 0 ))) { - RtlFreeHeap( GetProcessHeap(), 0, context ); + free( context ); return NULL; } return context; @@ -165,7 +165,7 @@ static struct wgl_context * CDECL osmesa_create_context( HDC hdc, const PIXELFOR static BOOL CDECL osmesa_delete_context( struct wgl_context *context ) { pOSMesaDestroyContext( context->context ); - RtlFreeHeap( GetProcessHeap(), 0, context ); + free( context ); return TRUE; } diff --git a/dlls/gdi32/driver.c b/dlls/gdi32/driver.c index f089d1b9c8d..24b8a6b27b5 100644 --- a/dlls/gdi32/driver.c +++ b/dlls/gdi32/driver.c @@ -39,7 +39,6 @@ #include "ntgdi_private.h" #include "wine/list.h" #include "wine/debug.h" -#include "wine/heap.h" WINE_DEFAULT_DEBUG_CHANNEL(driver); @@ -809,7 +808,7 @@ NTSTATUS WINAPI NtGdiDdDDICloseAdapter( const D3DKMT_CLOSEADAPTER *desc ) if (adapter->handle == desc->hAdapter) { list_remove( &adapter->entry ); - heap_free( adapter ); + free( adapter ); status = STATUS_SUCCESS; break; } @@ -847,7 +846,7 @@ NTSTATUS WINAPI NtGdiDdDDIOpenAdapterFromLuid( D3DKMT_OPENADAPTERFROMLUID *desc static D3DKMT_HANDLE handle_start = 0; struct d3dkmt_adapter *adapter; - if (!(adapter = heap_alloc( sizeof( *adapter ) ))) return STATUS_NO_MEMORY; + if (!(adapter = malloc( sizeof( *adapter ) ))) return STATUS_NO_MEMORY; EnterCriticalSection( &driver_section ); desc->hAdapter = adapter->handle = ++handle_start; @@ -888,7 +887,7 @@ NTSTATUS WINAPI NtGdiDdDDICreateDevice( D3DKMT_CREATEDEVICE *desc ) if (desc->Flags.LegacyMode || desc->Flags.RequestVSync || desc->Flags.DisableGpuTimeout) FIXME("Flags unsupported.\n"); - device = heap_alloc_zero( sizeof( *device ) ); + device = calloc( 1, sizeof( *device ) ); if (!device) return STATUS_NO_MEMORY; @@ -924,7 +923,7 @@ NTSTATUS WINAPI NtGdiDdDDIDestroyDevice( const D3DKMT_DESTROYDEVICE *desc ) set_owner_desc.hDevice = desc->hDevice; NtGdiDdDDISetVidPnSourceOwner( &set_owner_desc ); list_remove( &device->entry ); - heap_free( device ); + free( device ); status = STATUS_SUCCESS; break; } diff --git a/dlls/gdi32/emfdrv.c b/dlls/gdi32/emfdrv.c index 1208ab4b87a..e05f11d7b9a 100644 --- a/dlls/gdi32/emfdrv.c +++ b/dlls/gdi32/emfdrv.c @@ -445,7 +445,7 @@ static INT CDECL EMFDRV_GetDeviceCaps( PHYSDEV dev, INT cap ) static BOOL CDECL EMFDRV_DeleteDC( PHYSDEV dev ) { EMFDRV_PDEVICE *physDev = get_emf_physdev( dev ); - HeapFree( GetProcessHeap(), 0, physDev ); + free( physDev ); return TRUE; } @@ -577,7 +577,7 @@ HDC WINAPI NtGdiCreateMetafileDC( HDC hdc ) if (!(dc = alloc_dc_ptr( NTGDI_OBJ_ENHMETADC ))) return 0; - physDev = HeapAlloc( GetProcessHeap(), 0, sizeof(*physDev) ); + physDev = malloc( sizeof(*physDev) ); if (!physDev) { free_dc_ptr( dc ); diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c index 5864eb88498..98c70a6e2a8 100644 --- a/dlls/gdi32/font.c +++ b/dlls/gdi32/font.c @@ -37,7 +37,6 @@ #include "winreg.h" #include "ntgdi_private.h" #include "wine/exception.h" -#include "wine/heap.h" #include "wine/rbtree.h" #include "wine/debug.h" @@ -293,7 +292,7 @@ static inline WCHAR *strdupW( const WCHAR *p ) { WCHAR *ret; DWORD len = (lstrlenW(p) + 1) * sizeof(WCHAR); - ret = HeapAlloc(GetProcessHeap(), 0, len); + ret = malloc( len ); memcpy(ret, p, len); return ret; } @@ -720,8 +719,7 @@ static BOOL add_gdi_font_subst( const WCHAR *from_name, int from_charset, const if (get_gdi_font_subst( from_name, from_charset, NULL )) return FALSE; /* already exists */ - if (!(subst = HeapAlloc( GetProcessHeap(), 0, - offsetof( struct gdi_font_subst, names[len] )))) + if (!(subst = malloc( offsetof( struct gdi_font_subst, names[len] ) ))) return FALSE; lstrcpyW( subst->names, from_name ); lstrcpyW( get_subst_to_name(subst), to_name ); @@ -819,7 +817,7 @@ static int face_is_in_full_name_tree( const struct gdi_font_face *face ) static struct gdi_font_family *create_family( const WCHAR *name, const WCHAR *second_name ) { - struct gdi_font_family *family = HeapAlloc( GetProcessHeap(), 0, sizeof(*family) ); + struct gdi_font_family *family = malloc( sizeof(*family) ); family->refcount = 1; lstrcpynW( family->family_name, name, LF_FACESIZE ); @@ -843,7 +841,7 @@ static void release_family( struct gdi_font_family *family ) wine_rb_remove( &family_name_tree, &family->name_entry ); if (family->second_name[0]) wine_rb_remove( &family_second_name_tree, &family->second_name_entry ); if (family->replacement) release_family( family->replacement ); - HeapFree( GetProcessHeap(), 0, family ); + free( family ); } static struct gdi_font_family *find_family_from_name( const WCHAR *name ) @@ -1057,11 +1055,11 @@ static void release_face( struct gdi_font_face *face ) release_family( face->family ); } if (face_is_in_full_name_tree( face )) wine_rb_remove( &face_full_name_tree, &face->full_name_entry ); - HeapFree( GetProcessHeap(), 0, face->file ); - HeapFree( GetProcessHeap(), 0, face->style_name ); - HeapFree( GetProcessHeap(), 0, face->full_name ); - HeapFree( GetProcessHeap(), 0, face->cached_enum_data ); - HeapFree( GetProcessHeap(), 0, face ); + free( face->file ); + free( face->style_name ); + free( face->full_name ); + free( face->cached_enum_data ); + free( face ); } static int remove_font( const WCHAR *file, DWORD flags ) @@ -1179,7 +1177,7 @@ static struct gdi_font_face *create_face( struct gdi_font_family *family, const DWORD ntmflags, DWORD version, DWORD flags, const struct bitmap_font_size *size ) { - struct gdi_font_face *face = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*face) ); + struct gdi_font_face *face = calloc( 1, sizeof(*face) ); face->refcount = 1; face->style_name = strdupW( style ); @@ -1484,7 +1482,7 @@ static struct gdi_font_link *add_gdi_font_link( const WCHAR *name ) struct gdi_font_link *link = find_gdi_font_link( name ); if (link) return link; - if ((link = HeapAlloc( GetProcessHeap(), 0, sizeof(*link) ))) + if ((link = malloc( sizeof(*link) ))) { lstrcpynW( link->name, name, LF_FACESIZE ); memset( &link->fs, 0, sizeof(link->fs) ); @@ -1498,7 +1496,7 @@ static void add_gdi_font_link_entry( struct gdi_font_link *link, const WCHAR *fa { struct gdi_font_link_entry *entry; - entry = HeapAlloc( GetProcessHeap(), 0, sizeof(*entry) ); + entry = malloc( sizeof(*entry) ); lstrcpynW( entry->family_name, family_name, LF_FACESIZE ); entry->fs = fs; link->fs.fsCsb[0] |= fs.fsCsb[0]; @@ -1966,8 +1964,7 @@ static void free_font_handle( DWORD handle ) static struct gdi_font *alloc_gdi_font( const WCHAR *file, void *data_ptr, SIZE_T data_size ) { UINT len = file ? lstrlenW(file) : 0; - struct gdi_font *font = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, - offsetof( struct gdi_font, file[len + 1] )); + struct gdi_font *font = calloc( 1, offsetof( struct gdi_font, file[len + 1] )); font->refcount = 1; font->matrix.eM11 = font->matrix.eM22 = 1.0; @@ -2021,15 +2018,15 @@ static void free_gdi_font( struct gdi_font *font ) list_remove( &child->entry ); free_gdi_font( child ); } - for (i = 0; i < font->gm_size; i++) HeapFree( GetProcessHeap(), 0, font->gm[i] ); - HeapFree( GetProcessHeap(), 0, font->otm.otmpFamilyName ); - HeapFree( GetProcessHeap(), 0, font->otm.otmpStyleName ); - HeapFree( GetProcessHeap(), 0, font->otm.otmpFaceName ); - HeapFree( GetProcessHeap(), 0, font->otm.otmpFullName ); - HeapFree( GetProcessHeap(), 0, font->gm ); - HeapFree( GetProcessHeap(), 0, font->kern_pairs ); - HeapFree( GetProcessHeap(), 0, font->gsub_table ); - HeapFree( GetProcessHeap(), 0, font ); + for (i = 0; i < font->gm_size; i++) free( font->gm[i] ); + free( font->otm.otmpFamilyName ); + free( font->otm.otmpStyleName ); + free( font->otm.otmpFaceName ); + free( font->otm.otmpFullName ); + free( font->gm ); + free( font->kern_pairs ); + free( font->gsub_table ); + free( font ); } static inline const WCHAR *get_gdi_font_name( struct gdi_font *font ) @@ -2097,17 +2094,14 @@ static void set_gdi_font_glyph_metrics( struct gdi_font *font, UINT index, { struct glyph_metrics **ptr; - if (font->gm) - ptr = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, font->gm, (block + 1) * sizeof(*ptr) ); - else - ptr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, (block + 1) * sizeof(*ptr) ); - if (!ptr) return; + if (!(ptr = realloc( font->gm, (block + 1) * sizeof(*ptr) ))) return; + memset( ptr + font->gm_size, 0, (block + 1 - font->gm_size) * sizeof(*ptr) ); font->gm_size = block + 1; font->gm = ptr; } if (!font->gm[block]) { - font->gm[block] = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(**font->gm) * GM_BLOCK_SIZE ); + font->gm[block] = calloc( sizeof(**font->gm), GM_BLOCK_SIZE ); if (!font->gm[block]) return; } font->gm[block][entry].gm = *gm; @@ -2316,7 +2310,7 @@ static void *get_GSUB_vert_feature( struct gdi_font *font ) if (length == GDI_ERROR) return NULL; - header = HeapAlloc( GetProcessHeap(), 0, length ); + header = malloc( length ); font_funcs->get_font_data( font, MS_GSUB_TAG, 0, header, length ); TRACE( "Loaded GSUB table of %i bytes\n", length ); @@ -2337,7 +2331,7 @@ static void *get_GSUB_vert_feature( struct gdi_font *font ) } else TRACE("Script not found\n"); - HeapFree( GetProcessHeap(), 0, header ); + free( header ); return NULL; } @@ -2848,7 +2842,7 @@ static BOOL CDECL font_CreateDC( PHYSDEV *dev, LPCWSTR device, LPCWSTR output, struct font_physdev *physdev; if (!font_funcs) return TRUE; - if (!(physdev = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*physdev) ))) return FALSE; + if (!(physdev = calloc( 1, sizeof(*physdev) ))) return FALSE; push_dc_driver( dev, &physdev->dev, &font_driver ); return TRUE; } @@ -2862,7 +2856,7 @@ static BOOL CDECL font_DeleteDC( PHYSDEV dev ) struct font_physdev *physdev = get_font_dev( dev ); release_gdi_font( physdev->font ); - HeapFree( GetProcessHeap(), 0, physdev ); + free( physdev ); return TRUE; } @@ -3076,10 +3070,10 @@ static BOOL enum_face_charsets( const struct gdi_font_family *family, struct gdi { struct gdi_font_enum_data *data; - if (!(data = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data) )) || + if (!(data = calloc( 1, sizeof(*data) )) || !get_face_enum_data( face, &data->elf, &data->ntm )) { - HeapFree( GetProcessHeap(), 0, data ); + free( data ); return TRUE; } face->cached_enum_data = data; @@ -4466,13 +4460,13 @@ HFONT WINAPI NtGdiHfontCreate( const ENUMLOGFONTEXDVW *penumex, ULONG size, ULON } plf = &penumex->elfEnumLogfontEx.elfLogFont; - if (!(fontPtr = HeapAlloc( GetProcessHeap(), 0, sizeof(*fontPtr) ))) return 0; + if (!(fontPtr = malloc( sizeof(*fontPtr) ))) return 0; fontPtr->logfont = *plf; if (!(hFont = alloc_gdi_handle( &fontPtr->obj, NTGDI_OBJ_FONT, &fontobj_funcs ))) { - HeapFree( GetProcessHeap(), 0, fontPtr ); + free( fontPtr ); return 0; } @@ -4647,7 +4641,7 @@ static BOOL FONT_DeleteObject( HGDIOBJ handle ) FONTOBJ *obj; if (!(obj = free_gdi_handle( handle ))) return FALSE; - HeapFree( GetProcessHeap(), 0, obj ); + free( obj ); return TRUE; } @@ -4782,7 +4776,7 @@ BOOL WINAPI NtGdiGetTextExtentExW( HDC hdc, const WCHAR *str, INT count, INT max if (!dxs) { pos = buffer; - if (count > 256 && !(pos = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*pos) ))) + if (count > 256 && !(pos = malloc( count * sizeof(*pos) ))) { release_dc_ptr( dc ); return FALSE; @@ -4812,7 +4806,7 @@ BOOL WINAPI NtGdiGetTextExtentExW( HDC hdc, const WCHAR *str, INT count, INT max size->cy = abs( INTERNAL_YDSTOWS( dc, size->cy )); } - if (pos != buffer && pos != dxs) HeapFree( GetProcessHeap(), 0, pos ); + if (pos != buffer && pos != dxs) free( pos ); release_dc_ptr( dc ); TRACE("(%p, %s, %d) returning %dx%d\n", hdc, debugstr_wn(str,count), max_ext, size->cx, size->cy ); @@ -4894,7 +4888,7 @@ UINT WINAPI NtGdiGetOutlineTextMetricsInternalW( HDC hdc, UINT cbData, if (lpOTM && ret > cbData) { - output = HeapAlloc(GetProcessHeap(), 0, ret); + output = malloc( ret ); ret = dev->funcs->pGetOutlineTextMetrics( dev, ret, output ); } @@ -4938,7 +4932,7 @@ UINT WINAPI NtGdiGetOutlineTextMetricsInternalW( HDC hdc, UINT cbData, if(output != lpOTM) { memcpy(lpOTM, output, cbData); - HeapFree(GetProcessHeap(), 0, output); + free( output ); ret = cbData; } } @@ -4962,21 +4956,21 @@ BOOL WINAPI NtGdiGetCharWidthW( HDC hdc, UINT first, UINT last, WCHAR *chars, ABC *abc; unsigned int i; - if (!(abc = HeapAlloc(GetProcessHeap(), 0, count * sizeof(ABC)))) + if (!(abc = malloc( count * sizeof(ABC) ))) return FALSE; if (!NtGdiGetCharABCWidthsW( hdc, first, last, chars, NTGDI_GETCHARABCWIDTHS_INT | NTGDI_GETCHARABCWIDTHS_INDICES, abc )) { - HeapFree( GetProcessHeap(), 0, abc ); + free( abc ); return FALSE; } for (i = 0; i < count; i++) ((INT *)buf)[i] = abc[i].abcA + abc[i].abcB + abc[i].abcC; - HeapFree(GetProcessHeap(), 0, abc); + free( abc ); return TRUE; } @@ -5040,7 +5034,7 @@ static DWORD get_glyph_bitmap( HDC hdc, UINT index, UINT flags, UINT aa_flags, stride = get_dib_stride( metrics->gmBlackBoxX, 1 ); size = metrics->gmBlackBoxY * stride; - if (!(image->ptr = HeapAlloc( GetProcessHeap(), 0, size ))) return ERROR_OUTOFMEMORY; + if (!(image->ptr = malloc( size ))) return ERROR_OUTOFMEMORY; image->is_copy = TRUE; image->free = free_heap_bits; @@ -5048,7 +5042,7 @@ static DWORD get_glyph_bitmap( HDC hdc, UINT index, UINT flags, UINT aa_flags, &identity, FALSE ); if (ret == GDI_ERROR) { - HeapFree( GetProcessHeap(), 0, image->ptr ); + free( image->ptr ); return ERROR_NOT_FOUND; } return ERROR_SUCCESS; @@ -5112,7 +5106,7 @@ static void draw_glyph( DC *dc, INT origin_x, INT origin_y, const GLYPHMETRICS * else if (!intersect_rect( &clipped_rect, &rect, clip )) return; max_count = (metrics->gmBlackBoxX + 1) * metrics->gmBlackBoxY; - pts = HeapAlloc( GetProcessHeap(), 0, max_count * sizeof(*pts) ); + pts = malloc( max_count * sizeof(*pts) ); if (!pts) return; count = 0; @@ -5139,7 +5133,7 @@ static void draw_glyph( DC *dc, INT origin_x, INT origin_y, const GLYPHMETRICS * const UINT pts_count = 2; NtGdiPolyPolyDraw( dc->hSelf, pts + i, &pts_count, 1, NtGdiPolyPolyline ); } - HeapFree( GetProcessHeap(), 0, pts ); + free( pts ); } /*********************************************************************** @@ -5211,7 +5205,7 @@ BOOL CDECL nulldrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT src.visrect.right = src.width; src.visrect.bottom = src.height; - bits.ptr = HeapAlloc( GetProcessHeap(), 0, info->bmiHeader.biSizeImage ); + bits.ptr = malloc( info->bmiHeader.biSizeImage ); if (!bits.ptr) return ERROR_OUTOFMEMORY; bits.is_copy = TRUE; bits.free = free_heap_bits; @@ -5224,7 +5218,7 @@ BOOL CDECL nulldrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT err = src_dev->funcs->pGetImage( src_dev, info, &bits, &src ); if (!err && !bits.is_copy) { - void *ptr = HeapAlloc( GetProcessHeap(), 0, info->bmiHeader.biSizeImage ); + void *ptr = malloc( info->bmiHeader.biSizeImage ); if (!ptr) { if (bits.free) bits.free( &bits ); @@ -5436,7 +5430,7 @@ BOOL WINAPI NtGdiExtTextOutW( HDC hdc, INT x, INT y, UINT flags, const RECT *lpr UINT i; POINT total = {0, 0}, desired[2]; - deltas = HeapAlloc(GetProcessHeap(), 0, count * sizeof(*deltas)); + deltas = malloc( count * sizeof(*deltas) ); if (lpDx) { if (flags & ETO_PDY) @@ -5458,7 +5452,7 @@ BOOL WINAPI NtGdiExtTextOutW( HDC hdc, INT x, INT y, UINT flags, const RECT *lpr } else { - INT *dx = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*dx) ); + INT *dx = malloc( count * sizeof(*dx) ); NtGdiGetTextExtentExW( hdc, str, count, -1, NULL, dx, &sz, !!(flags & ETO_GLYPH_INDEX) ); @@ -5469,7 +5463,7 @@ BOOL WINAPI NtGdiExtTextOutW( HDC hdc, INT x, INT y, UINT flags, const RECT *lpr deltas[i].x = dx[i] - dx[i - 1]; deltas[i].y = 0; } - HeapFree( GetProcessHeap(), 0, dx ); + free( dx ); } for(i = 0; i < count; i++) @@ -5596,7 +5590,7 @@ BOOL WINAPI NtGdiExtTextOutW( HDC hdc, INT x, INT y, UINT flags, const RECT *lpr str, count, (INT*)deltas ); done: - HeapFree(GetProcessHeap(), 0, deltas); + free( deltas ); if (ret && (lf.lfUnderline || lf.lfStrikeOut)) { @@ -5619,7 +5613,7 @@ done: } else { - otm = HeapAlloc(GetProcessHeap(), 0, size); + otm = malloc( size ); NtGdiGetOutlineTextMetricsInternalW( hdc, size, otm, 0 ); underlinePos = abs( INTERNAL_YWSTODS( dc, otm->otmsUnderscorePosition )); if (otm->otmsUnderscorePosition < 0) underlinePos = -underlinePos; @@ -5627,7 +5621,7 @@ done: strikeoutPos = abs( INTERNAL_YWSTODS( dc, otm->otmsStrikeoutPosition )); if (otm->otmsStrikeoutPosition < 0) strikeoutPos = -strikeoutPos; strikeoutWidth = get_line_width( dc, otm->otmsStrikeoutSize ); - HeapFree(GetProcessHeap(), 0, otm); + free( otm ); } @@ -6111,7 +6105,7 @@ static void update_external_font_keys(void) continue; } if (tmp && !*tmp) *tmp = ' '; - if (!(key = HeapAlloc( GetProcessHeap(), 0, sizeof(*key) ))) break; + if (!(key = malloc( sizeof(*key) ))) break; lstrcpyW( key->value, value ); list_add_tail( &external_keys, &key->entry ); } @@ -6148,7 +6142,7 @@ static void update_external_font_keys(void) reg_delete_value( winnt_key, key->value ); reg_delete_value( hkey, key->value ); list_remove( &key->entry ); - HeapFree( GetProcessHeap(), 0, key ); + free( key ); } NtClose( win9x_key ); NtClose( winnt_key ); @@ -6299,7 +6293,7 @@ HANDLE WINAPI NtGdiAddFontMemResourceEx( void *ptr, DWORD size, void *dv, ULONG return NULL; } if (!font_funcs) return NULL; - if (!(copy = HeapAlloc( GetProcessHeap(), 0, size ))) return NULL; + if (!(copy = malloc( size ))) return NULL; memcpy( copy, ptr, size ); EnterCriticalSection( &font_cs ); @@ -6308,7 +6302,7 @@ HANDLE WINAPI NtGdiAddFontMemResourceEx( void *ptr, DWORD size, void *dv, ULONG if (!num_fonts) { - HeapFree( GetProcessHeap(), 0, copy ); + free( copy ); return NULL; } diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index 2a67fa76062..d8bae670d7f 100644 --- a/dlls/gdi32/freetype.c +++ b/dlls/gdi32/freetype.c @@ -425,7 +425,7 @@ static char **expand_mac_font(const char *path) ret.size = 0; ret.max_size = 10; - ret.array = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, ret.max_size * sizeof(*ret.array)); + ret.array = calloc( ret.max_size, sizeof(*ret.array) ); if(!ret.array) { CloseResFile(res_ref); @@ -485,7 +485,7 @@ static char **expand_mac_font(const char *path) continue; } - output = RtlAllocateHeap(GetProcessHeap(), 0, output_len); + output = malloc( output_len); if(output) { int fd; @@ -507,15 +507,16 @@ static char **expand_mac_font(const char *path) } if(ret.size >= ret.max_size - 1) /* Always want the last element to be NULL */ { + ret.array = realloc( ret.array, ret.max_size * sizeof(*ret.array) * 2 ); + memset( ret.array + ret.max_size, 0, ret.max_size * sizeof(*ret.array) ); ret.max_size *= 2; - ret.array = RtlReAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, ret.array, ret.max_size * sizeof(*ret.array)); } ret.array[ret.size++] = output; } else { WARN("unable to create %s\n", output); - RtlFreeHeap(GetProcessHeap(), 0, output); + free( output ); } } ReleaseResource(sfnt); @@ -592,7 +593,7 @@ static LPWSTR strdupW(LPCWSTR p) { LPWSTR ret; DWORD len = (lstrlenW(p) + 1) * sizeof(WCHAR); - ret = RtlAllocateHeap(GetProcessHeap(), 0, len); + ret = malloc( len ); memcpy(ret, p, len); return ret; } @@ -600,7 +601,7 @@ static LPWSTR strdupW(LPCWSTR p) static WCHAR *towstr(const char *str) { DWORD len = strlen(str) + 1; - WCHAR *wstr = RtlAllocateHeap( GetProcessHeap(), 0, len * sizeof(WCHAR) ); + WCHAR *wstr = malloc( len * sizeof(WCHAR) ); RtlMultiByteToUnicodeN( wstr, len * sizeof(WCHAR), &len, str, len ); return wstr; } @@ -796,14 +797,14 @@ static WCHAR *copy_name_table_string( const FT_SfntName *name ) { case TT_PLATFORM_APPLE_UNICODE: case TT_PLATFORM_MICROSOFT: - ret = RtlAllocateHeap( GetProcessHeap(), 0, name->string_len + sizeof(WCHAR) ); + ret = malloc( name->string_len + sizeof(WCHAR) ); for (i = 0; i < name->string_len / 2; i++) ret[i] = (name->string[i * 2] << 8) | name->string[i * 2 + 1]; ret[i] = 0; return ret; case TT_PLATFORM_MACINTOSH: if (!(cp = get_mac_code_page( name ))) return NULL; - ret = RtlAllocateHeap( GetProcessHeap(), 0, (name->string_len + 1) * sizeof(WCHAR) ); + ret = malloc( (name->string_len + 1) * sizeof(WCHAR) ); RtlCustomCPToUnicodeN( cp, ret, name->string_len * sizeof(WCHAR), &i, (char *)name->string, name->string_len ); ret[i / sizeof(WCHAR)] = 0; @@ -877,11 +878,11 @@ static WCHAR *ft_face_get_full_name( FT_Face ft_face, LANGID langid ) style_name = ft_face_get_style_name( ft_face, langid ); length = lstrlenW( full_name ) + lstrlenW( space_w ) + lstrlenW( style_name ) + 1; - full_name = RtlReAllocateHeap( GetProcessHeap(), 0, full_name, length * sizeof(WCHAR) ); + full_name = realloc( full_name, length * sizeof(WCHAR) ); lstrcatW( full_name, space_w ); lstrcatW( full_name, style_name ); - RtlFreeHeap( GetProcessHeap(), 0, style_name ); + free( style_name ); WARN( "full name not found, using %s instead\n", debugstr_w(full_name) ); return full_name; @@ -1219,7 +1220,7 @@ static struct unix_face *unix_face_create( const char *unix_name, void *data_ptr if (data_ptr == MAP_FAILED) return NULL; } - if (!(This = RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This) ))) goto done; + if (!(This = calloc( 1, sizeof(*This) ))) goto done; if (opentype_get_ttc_sfnt_v1( data_ptr, data_size, face_index, &face_count, &ttc_sfnt_v1 ) && opentype_get_tt_name_v0( data_ptr, data_size, ttc_sfnt_v1, &tt_name_v0 ) && @@ -1259,7 +1260,7 @@ static struct unix_face *unix_face_create( const char *unix_name, void *data_ptr if (!This->full_name && This->family_name && This->style_name) { length = lstrlenW( This->family_name ) + lstrlenW( space_w ) + lstrlenW( This->style_name ) + 1; - This->full_name = RtlAllocateHeap( GetProcessHeap(), 0, length * sizeof(WCHAR) ); + This->full_name = malloc( length * sizeof(WCHAR) ); lstrcpyW( This->full_name, This->family_name ); lstrcatW( This->full_name, space_w ); lstrcatW( This->full_name, This->style_name ); @@ -1279,12 +1280,12 @@ static struct unix_face *unix_face_create( const char *unix_name, void *data_ptr if (!RtlCompareUnicodeStrings( This->family_name, lstrlenW( This->family_name ), This->second_name, lstrlenW( This->second_name ), TRUE )) { - RtlFreeHeap( GetProcessHeap(), 0, This->second_name ); + free( This->second_name ); This->second_name = ft_face_get_family_name( This->ft_face, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) ); if (!RtlCompareUnicodeStrings( This->family_name, lstrlenW( This->family_name ), This->second_name, lstrlenW( This->second_name ), TRUE )) { - RtlFreeHeap( GetProcessHeap(), 0, This->second_name ); + free( This->second_name ); This->second_name = NULL; } } @@ -1299,7 +1300,7 @@ static struct unix_face *unix_face_create( const char *unix_name, void *data_ptr } else { - RtlFreeHeap( GetProcessHeap(), 0, This ); + free( This ); This = NULL; } @@ -1311,11 +1312,11 @@ done: static void unix_face_destroy( struct unix_face *This ) { if (This->ft_face) pFT_Done_Face( This->ft_face ); - RtlFreeHeap( GetProcessHeap(), 0, This->full_name ); - RtlFreeHeap( GetProcessHeap(), 0, This->style_name ); - RtlFreeHeap( GetProcessHeap(), 0, This->second_name ); - RtlFreeHeap( GetProcessHeap(), 0, This->family_name ); - RtlFreeHeap( GetProcessHeap(), 0, This ); + free( This->full_name ); + free( This->style_name ); + free( This->second_name ); + free( This->family_name ); + free( This ); } static int add_unix_face( const char *unix_name, const WCHAR *file, void *data_ptr, SIZE_T data_size, @@ -1356,10 +1357,10 @@ static WCHAR *get_dos_file_name( LPCSTR str ) ULONG len = strlen(str) + 1; len += 8; /* \??\unix prefix */ - if (!(buffer = RtlAllocateHeap( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return NULL; + if (!(buffer = malloc( len * sizeof(WCHAR) ))) return NULL; if (wine_unix_to_nt_file_name( str, buffer, &len )) { - RtlFreeHeap( GetProcessHeap(), 0, buffer ); + free( buffer ); return NULL; } return buffer; @@ -1377,19 +1378,19 @@ static char *get_unix_file_name( LPCWSTR dosW ) InitializeObjectAttributes( &attr, &nt_name, 0, 0, NULL ); for (;;) { - if (!(buffer = RtlAllocateHeap( GetProcessHeap(), 0, size ))) + if (!(buffer = malloc( size ))) { RtlFreeUnicodeString( &nt_name ); return NULL; } status = wine_nt_to_unix_file_name( &attr, buffer, &size, FILE_OPEN_IF ); if (status != STATUS_BUFFER_TOO_SMALL) break; - RtlFreeHeap( GetProcessHeap(), 0, buffer ); + free( buffer ); } RtlFreeUnicodeString( &nt_name ); if (status && status != STATUS_NO_SUCH_FILE) { - RtlFreeHeap( GetProcessHeap(), 0, buffer ); + free( buffer ); RtlSetLastWin32ErrorAndNtStatusFromNtStatus( status ); return NULL; } @@ -1418,9 +1419,9 @@ static INT AddFontToList(const WCHAR *dos_name, const char *unix_name, void *fon { had_one = TRUE; AddFontToList(NULL, *cursor, NULL, 0, flags); - RtlFreeHeap(GetProcessHeap(), 0, *cursor); + free( *cursor ); } - RtlFreeHeap(GetProcessHeap(), 0, mac_list); + free( mac_list ); if(had_one) return 1; } @@ -1433,7 +1434,7 @@ static INT AddFontToList(const WCHAR *dos_name, const char *unix_name, void *fon ret += add_unix_face( unix_name, dos_name, font_data_ptr, font_data_size, face_index, flags, &num_faces ); while (num_faces > ++face_index); - RtlFreeHeap( GetProcessHeap(), 0, filename ); + free( filename ); return ret; } @@ -1448,7 +1449,7 @@ static INT CDECL freetype_add_font( const WCHAR *file, DWORD flags ) if (unixname) { ret = AddFontToList( file, unixname, NULL, 0, flags ); - RtlFreeHeap( GetProcessHeap(), 0, unixname ); + free( unixname ); } return ret; } @@ -1595,7 +1596,7 @@ static void fontconfig_add_font( FcPattern *pattern, DWORD flags ) dos_name = get_dos_file_name( unix_name ); add_unix_face( unix_name, dos_name, NULL, 0, face_index, flags, NULL ); - RtlFreeHeap( GetProcessHeap(), 0, dos_name ); + free( dos_name ); } static void init_fontconfig(void) @@ -1729,13 +1730,13 @@ static void load_mac_font_callback(const void *value, void *context) char* path; len = CFStringGetMaximumSizeOfFileSystemRepresentation(pathStr); - path = RtlAllocateHeap(GetProcessHeap(), 0, len); + path = malloc( len ); if (path && CFStringGetFileSystemRepresentation(pathStr, path, len)) { TRACE("font file %s\n", path); AddFontToList(NULL, path, NULL, 0, ADDFONT_EXTERNAL_FONT); } - RtlFreeHeap(GetProcessHeap(), 0, path); + free( path ); } static void load_mac_fonts(void) @@ -2023,7 +2024,7 @@ static struct font_mapping *map_font_file( const char *name ) return mapping; } } - if (!(mapping = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*mapping) ))) + if (!(mapping = malloc( sizeof(*mapping) ))) goto error; mapping->data = mmap( NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0 ); @@ -2031,7 +2032,7 @@ static struct font_mapping *map_font_file( const char *name ) if (mapping->data == MAP_FAILED) { - RtlFreeHeap( GetProcessHeap(), 0, mapping ); + free( mapping ); return NULL; } mapping->refcount = 1; @@ -2052,7 +2053,7 @@ static void unmap_font_file( struct font_mapping *mapping ) { list_remove( &mapping->entry ); munmap( mapping->data, mapping->size ); - RtlFreeHeap( GetProcessHeap(), 0, mapping ); + free( mapping ); } } @@ -2067,7 +2068,7 @@ static void CDECL freetype_destroy_font( struct gdi_font *font ) if (data->ft_face) pFT_Done_Face( data->ft_face ); if (data->mapping) unmap_font_file( data->mapping ); - RtlFreeHeap( GetProcessHeap(), 0, data ); + free( data ); } /************************************************************* @@ -2209,7 +2210,7 @@ static LONG load_VDMX(struct gdi_font *font, LONG height) TRACE("recs=%d startsz=%d endsz=%d\n", recs, startsz, endsz); - vTable = RtlAllocateHeap(GetProcessHeap(), 0, recs * sizeof(VDMX_vTable)); + vTable = malloc( recs * sizeof(VDMX_vTable) ); result = freetype_get_font_data(font, MS_VDMX_TAG, offset + sizeof(group), vTable, recs * sizeof(VDMX_vTable)); if(result == GDI_ERROR) { FIXME("Failed to retrieve vTable\n"); @@ -2271,7 +2272,7 @@ static LONG load_VDMX(struct gdi_font *font, LONG height) } } end: - RtlFreeHeap(GetProcessHeap(), 0, vTable); + free( vTable ); } return ppem; @@ -2366,7 +2367,7 @@ static BOOL get_gasp_flags( struct gdi_font *font, WORD *flags ) if (size < 4 * sizeof(WORD)) return FALSE; if (size > sizeof(buf)) { - ptr = alloced = RtlAllocateHeap( GetProcessHeap(), 0, size ); + ptr = alloced = malloc( size ); if (!ptr) return FALSE; } @@ -2391,7 +2392,7 @@ static BOOL get_gasp_flags( struct gdi_font *font, WORD *flags ) ret = TRUE; done: - RtlFreeHeap( GetProcessHeap(), 0, alloced ); + free( alloced ); return ret; } @@ -2447,14 +2448,14 @@ static BOOL CDECL freetype_load_font( struct gdi_font *font ) void *data_ptr; SIZE_T data_size; - if (!(data = RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data) ))) return FALSE; + if (!(data = calloc( 1, sizeof(*data) ))) return FALSE; font->private = data; if (font->file[0]) { char *filename = get_unix_file_name( font->file ); data->mapping = map_font_file( filename ); - RtlFreeHeap( GetProcessHeap(), 0, filename ); + free( filename ); if (!data->mapping) { WARN("failed to map %s\n", debugstr_w(font->file)); @@ -4182,16 +4183,16 @@ static DWORD CDECL freetype_get_kerning_pairs( struct gdi_font *font, KERNINGPAI return 0; } - buf = RtlAllocateHeap(GetProcessHeap(), 0, length); + buf = malloc( length ); if (!buf) return 0; freetype_get_font_data(font, MS_KERN_TAG, 0, buf, length); /* build a glyph index to char code map */ - glyph_to_char = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(USHORT) * 65536); + glyph_to_char = calloc( sizeof(USHORT), 65536 ); if (!glyph_to_char) { - RtlFreeHeap(GetProcessHeap(), 0, buf); + free( buf ); return 0; } @@ -4260,10 +4261,7 @@ static DWORD CDECL freetype_get_kerning_pairs( struct gdi_font *font, KERNINGPAI glyph_to_char, NULL, 0); count += new_chunk; - if (!*pairs) - *pairs = RtlAllocateHeap(GetProcessHeap(), 0, count * sizeof(**pairs)); - else - *pairs = RtlReAllocateHeap(GetProcessHeap(), 0, *pairs, count * sizeof(**pairs)); + *pairs = realloc( *pairs, count * sizeof(**pairs)); parse_format0_kern_subtable(font, (const struct TT_format0_kern_subtable *)(tt_kern_subtable + 1), glyph_to_char, *pairs + old_total, new_chunk); @@ -4274,8 +4272,8 @@ static DWORD CDECL freetype_get_kerning_pairs( struct gdi_font *font, KERNINGPAI tt_kern_subtable = (const struct TT_kern_subtable *)((const char *)tt_kern_subtable + tt_kern_subtable_copy.length); } - RtlFreeHeap(GetProcessHeap(), 0, glyph_to_char); - RtlFreeHeap(GetProcessHeap(), 0, buf); + free( glyph_to_char ); + free( buf ); return count; } diff --git a/dlls/gdi32/gdiobj.c b/dlls/gdi32/gdiobj.c index 540ff4c0697..47b413ab0aa 100644 --- a/dlls/gdi32/gdiobj.c +++ b/dlls/gdi32/gdiobj.c @@ -947,11 +947,11 @@ HANDLE WINAPI NtGdiCreateClientObj( ULONG type ) struct gdi_obj_header *obj; HGDIOBJ handle; - if (!(obj = HeapAlloc( GetProcessHeap(), 0, sizeof(*obj) ))) + if (!(obj = malloc( sizeof(*obj) ))) return 0; handle = alloc_gdi_handle( obj, type, NULL ); - if (!handle) HeapFree( GetProcessHeap(), 0, obj ); + if (!handle) free( obj ); return handle; } @@ -962,7 +962,7 @@ BOOL WINAPI NtGdiDeleteClientObj( HGDIOBJ handle ) { void *obj; if (!(obj = free_gdi_handle( handle ))) return FALSE; - HeapFree( GetProcessHeap(), 0, obj ); + free( obj ); return TRUE; } diff --git a/dlls/gdi32/painting.c b/dlls/gdi32/painting.c index 629d6a1adef..b0e1ad117c0 100644 --- a/dlls/gdi32/painting.c +++ b/dlls/gdi32/painting.c @@ -131,7 +131,7 @@ BOOL CDECL nulldrv_PolyBezier( PHYSDEV dev, const POINT *points, DWORD count ) if ((pts = GDI_Bezier( points, count, &n ))) { ret = polyline( dev->hdc, pts, n ); - HeapFree( GetProcessHeap(), 0, pts ); + free( pts ); } return ret; } @@ -140,7 +140,7 @@ BOOL CDECL nulldrv_PolyBezierTo( PHYSDEV dev, const POINT *points, DWORD count ) { DC *dc = get_nulldrv_dc( dev ); BOOL ret = FALSE; - POINT *pts = HeapAlloc( GetProcessHeap(), 0, sizeof(POINT) * (count + 1) ); + POINT *pts = malloc( sizeof(POINT) * (count + 1) ); if (pts) { @@ -148,7 +148,7 @@ BOOL CDECL nulldrv_PolyBezierTo( PHYSDEV dev, const POINT *points, DWORD count ) memcpy( pts + 1, points, sizeof(POINT) * count ); count++; ret = NtGdiPolyPolyDraw( dev->hdc, pts, &count, 1, NtGdiPolyBezier ); - HeapFree( GetProcessHeap(), 0, pts ); + free( pts ); } return ret; } @@ -181,7 +181,7 @@ BOOL CDECL nulldrv_PolyDraw( PHYSDEV dev, const POINT *points, const BYTE *types } space = count + 300; - line_pts = HeapAlloc( GetProcessHeap(), 0, space * sizeof(POINT) ); + line_pts = malloc( space * sizeof(POINT) ); num_pts = 1; line_pts[0] = dc->attr->cur_pos; @@ -209,11 +209,11 @@ BOOL CDECL nulldrv_PolyDraw( PHYSDEV dev, const POINT *points, const BYTE *types if (space < size) { space = size * 2; - line_pts = HeapReAlloc( GetProcessHeap(), 0, line_pts, space * sizeof(POINT) ); + line_pts = realloc( line_pts, space * sizeof(POINT) ); } memcpy( &line_pts[num_pts], &bzr_pts[1], (num_bzr_pts - 1) * sizeof(POINT) ); num_pts += num_bzr_pts - 1; - HeapFree( GetProcessHeap(), 0, bzr_pts ); + free( bzr_pts ); } i += 2; break; @@ -222,7 +222,7 @@ BOOL CDECL nulldrv_PolyDraw( PHYSDEV dev, const POINT *points, const BYTE *types } if (num_pts >= 2) polyline( dev->hdc, line_pts, num_pts ); - HeapFree( GetProcessHeap(), 0, line_pts ); + free( line_pts ); return TRUE; } @@ -233,12 +233,12 @@ BOOL CDECL nulldrv_PolylineTo( PHYSDEV dev, const POINT *points, INT count ) POINT *pts; if (!count) return FALSE; - if ((pts = HeapAlloc( GetProcessHeap(), 0, sizeof(POINT) * (count + 1) ))) + if ((pts = malloc( sizeof(POINT) * (count + 1) ))) { pts[0] = dc->attr->cur_pos; memcpy( pts + 1, points, sizeof(POINT) * count ); ret = polyline( dev->hdc, pts, count + 1 ); - HeapFree( GetProcessHeap(), 0, pts ); + free( pts ); } return ret; } @@ -789,8 +789,7 @@ static void GDI_InternalBezier( POINT *Points, POINT **PtsOut, INT *dwOut, { if(*nPtsOut == *dwOut) { *dwOut *= 2; - *PtsOut = HeapReAlloc( GetProcessHeap(), 0, *PtsOut, - *dwOut * sizeof(POINT) ); + *PtsOut = realloc( *PtsOut, *dwOut * sizeof(POINT) ); } if(!level || BezierCheck(level, Points)) { @@ -842,7 +841,7 @@ static void GDI_InternalBezier( POINT *Points, POINT **PtsOut, INT *dwOut, * * Ptr to an array of POINTs that contain the lines that approximate the * Beziers. The array is allocated on the process heap and it is the caller's - * responsibility to HeapFree it. [this is not a particularly nice interface + * responsibility to free it. [this is not a particularly nice interface * but since we can't know in advance how many points we will generate, the * alternative would be to call the function twice, once to determine the size * and a second time to do the work - I decided this was too much of a pain]. @@ -857,7 +856,7 @@ POINT *GDI_Bezier( const POINT *Points, INT count, INT *nPtsOut ) return NULL; } *nPtsOut = 0; - out = HeapAlloc( GetProcessHeap(), 0, dwOut * sizeof(POINT)); + out = malloc( dwOut * sizeof(POINT) ); for(Bezier = 0; Bezier < (count-1)/3; Bezier++) { POINT ptBuf[4]; memcpy(ptBuf, Points + Bezier * 3, sizeof(POINT) * 4); diff --git a/dlls/gdi32/palette.c b/dlls/gdi32/palette.c index 7c623dd6739..8e9e51295bb 100644 --- a/dlls/gdi32/palette.c +++ b/dlls/gdi32/palette.c @@ -111,21 +111,21 @@ HPALETTE WINAPI NtGdiCreatePaletteInternal( const LOGPALETTE *palette, UINT coun if (!palette) return 0; TRACE( "entries=%u\n", count ); - if (!(palettePtr = HeapAlloc( GetProcessHeap(), 0, sizeof(*palettePtr) ))) return 0; + if (!(palettePtr = malloc( sizeof(*palettePtr) ))) return 0; palettePtr->unrealize = NULL; palettePtr->version = palette->palVersion; palettePtr->count = count; size = palettePtr->count * sizeof(*palettePtr->entries); - if (!(palettePtr->entries = HeapAlloc( GetProcessHeap(), 0, size ))) + if (!(palettePtr->entries = malloc( size ))) { - HeapFree( GetProcessHeap(), 0, palettePtr ); + free( palettePtr ); return 0; } memcpy( palettePtr->entries, palette->palPalEntry, size ); if (!(hpalette = alloc_gdi_handle( &palettePtr->obj, NTGDI_OBJ_PAL, &palette_funcs ))) { - HeapFree( GetProcessHeap(), 0, palettePtr->entries ); - HeapFree( GetProcessHeap(), 0, palettePtr ); + free( palettePtr->entries ); + free( palettePtr ); } TRACE(" returning %p\n", hpalette); return hpalette; @@ -228,22 +228,23 @@ static UINT set_palette_entries( HPALETTE hpalette, UINT start, UINT count, * * Resizes logical palette. */ -BOOL WINAPI NtGdiResizePalette( HPALETTE hPal, UINT cEntries ) +BOOL WINAPI NtGdiResizePalette( HPALETTE hPal, UINT count ) { PALETTEOBJ * palPtr = GDI_GetObjPtr( hPal, NTGDI_OBJ_PAL ); PALETTEENTRY *entries; if( !palPtr ) return FALSE; - TRACE("hpal = %p, prev = %i, new = %i\n", hPal, palPtr->count, cEntries ); + TRACE("hpal = %p, prev = %i, new = %i\n", hPal, palPtr->count, count ); - if (!(entries = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, - palPtr->entries, cEntries * sizeof(*palPtr->entries) ))) + if (!(entries = realloc( palPtr->entries, count * sizeof(*palPtr->entries) ))) { GDI_ReleaseObj( hPal ); return FALSE; } + if (count > palPtr->count) + memset( entries + palPtr->count, 0, (count - palPtr->count) * sizeof(*palPtr->entries) ); palPtr->entries = entries; - palPtr->count = cEntries; + palPtr->count = count; GDI_ReleaseObj( hPal ); PALETTE_UnrealizeObject( hPal ); @@ -505,8 +506,8 @@ static BOOL PALETTE_DeleteObject( HGDIOBJ handle ) PALETTE_UnrealizeObject( handle ); if (!(obj = free_gdi_handle( handle ))) return FALSE; - HeapFree( GetProcessHeap(), 0, obj->entries ); - HeapFree( GetProcessHeap(), 0, obj ); + free( obj->entries ); + free( obj ); return TRUE; } diff --git a/dlls/gdi32/path.c b/dlls/gdi32/path.c index e10c89e300b..59f38ae1538 100644 --- a/dlls/gdi32/path.c +++ b/dlls/gdi32/path.c @@ -106,13 +106,13 @@ static inline struct path_physdev *get_path_physdev( PHYSDEV dev ) void free_gdi_path( struct gdi_path *path ) { if (path->points != path->points_buf) - HeapFree( GetProcessHeap(), 0, path->points ); - HeapFree( GetProcessHeap(), 0, path ); + free( path->points ); + free( path ); } static struct gdi_path *alloc_gdi_path( int count ) { - struct gdi_path *path = HeapAlloc( GetProcessHeap(), 0, sizeof(*path) ); + struct gdi_path *path = malloc( sizeof(*path) ); if (!path) { @@ -122,11 +122,10 @@ static struct gdi_path *alloc_gdi_path( int count ) count = max( NUM_ENTRIES_INITIAL, count ); if (count > NUM_ENTRIES_INITIAL) { - path->points = HeapAlloc( GetProcessHeap(), 0, - count * (sizeof(path->points[0]) + sizeof(path->flags[0])) ); + path->points = malloc( count * (sizeof(path->points[0]) + sizeof(path->flags[0])) ); if (!path->points) { - HeapFree( GetProcessHeap(), 0, path ); + free( path ); SetLastError( ERROR_NOT_ENOUGH_MEMORY ); return NULL; } @@ -205,14 +204,14 @@ static BOOL PATH_ReserveEntries(struct gdi_path *path, INT count) if (path->points == path->points_buf) { - pts_new = HeapAlloc( GetProcessHeap(), 0, size ); + pts_new = malloc( size ); if (!pts_new) return FALSE; memcpy( pts_new, path->points, path->count * sizeof(path->points[0]) ); memcpy( pts_new + count, path->flags, path->count * sizeof(path->flags[0]) ); } else { - pts_new = HeapReAlloc( GetProcessHeap(), 0, path->points, size ); + pts_new = realloc( path->points, size ); if (!pts_new) return FALSE; memmove( pts_new + count, pts_new + path->allocated, path->count * sizeof(path->flags[0]) ); } @@ -339,7 +338,7 @@ static HRGN path_to_region( const struct gdi_path *path, int mode ) if (!path->count) return 0; - if (!(counts = HeapAlloc( GetProcessHeap(), 0, (path->count / 2) * sizeof(*counts) ))) return 0; + if (!(counts = malloc( (path->count / 2) * sizeof(*counts) ))) return 0; pos = polygons = 0; assert( path->flags[0] == PT_MOVETO ); @@ -353,7 +352,7 @@ static HRGN path_to_region( const struct gdi_path *path, int mode ) assert( polygons <= path->count / 2 ); hrgn = create_polypolygon_region( path->points, counts, polygons, mode, NULL ); - HeapFree( GetProcessHeap(), 0, counts ); + free( counts ); return hrgn; } @@ -410,7 +409,7 @@ static BOOL PATH_AddFlatBezier(struct gdi_path *pPath, POINT *pt, BOOL closed) ret = (add_points( pPath, pts + 1, no - 1, PT_LINETO ) != NULL); if (ret && closed) close_figure( pPath ); - HeapFree( GetProcessHeap(), 0, pts ); + free( pts ); return ret; } @@ -763,7 +762,7 @@ static BOOL CDECL pathdrv_EndPath( PHYSDEV dev ) dc->path = physdev->path; pop_dc_driver( dc, &path_driver ); - HeapFree( GetProcessHeap(), 0, physdev ); + free( physdev ); return TRUE; } @@ -774,7 +773,7 @@ static BOOL CDECL pathdrv_EndPath( PHYSDEV dev ) static BOOL CDECL pathdrv_CreateDC( PHYSDEV *dev, LPCWSTR device, LPCWSTR output, const DEVMODEW *devmode ) { - struct path_physdev *physdev = HeapAlloc( GetProcessHeap(), 0, sizeof(*physdev) ); + struct path_physdev *physdev = malloc( sizeof(*physdev) ); if (!physdev) return FALSE; push_dc_driver( dev, &physdev->dev, &path_driver ); @@ -790,7 +789,7 @@ static BOOL CDECL pathdrv_DeleteDC( PHYSDEV dev ) struct path_physdev *physdev = get_path_physdev( dev ); free_gdi_path( physdev->path ); - HeapFree( GetProcessHeap(), 0, physdev ); + free( physdev ); return TRUE; } @@ -822,7 +821,7 @@ BOOL PATH_RestorePath( DC *dst, DC *src ) { physdev = get_path_physdev( dev ); free_gdi_path( physdev->path ); - HeapFree( GetProcessHeap(), 0, physdev ); + free( physdev ); } if (src->path && src->path_open) @@ -1483,7 +1482,7 @@ static BOOL PATH_add_outline(struct path_physdev *physdev, INT x, INT y, { WORD i; POINTFX ptfx; - POINT *pts = HeapAlloc(GetProcessHeap(), 0, (curve->cpfx + 1) * sizeof(POINT)); + POINT *pts = malloc( (curve->cpfx + 1) * sizeof(POINT) ); if (!pts) return FALSE; @@ -1500,7 +1499,7 @@ static BOOL PATH_add_outline(struct path_physdev *physdev, INT x, INT y, PATH_BezierTo(physdev->path, pts, curve->cpfx + 1); - HeapFree(GetProcessHeap(), 0, pts); + free( pts ); break; } @@ -1545,13 +1544,13 @@ static BOOL CDECL pathdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, con /* add outline only if char is printable */ if(dwSize) { - outline = HeapAlloc(GetProcessHeap(), 0, dwSize); + outline = malloc( dwSize ); if (!outline) return FALSE; NtGdiGetGlyphOutline( dev->hdc, str[idx], ggo_flags, &gm, dwSize, outline, &identity, FALSE ); PATH_add_outline(physdev, x + offset.x, y + offset.y, outline, dwSize); - HeapFree(GetProcessHeap(), 0, outline); + free( outline ); } if (dx) @@ -1628,7 +1627,7 @@ static struct gdi_path *PATH_WidenPath(DC *dc) return NULL; } - elp = HeapAlloc( GetProcessHeap(), 0, size ); + elp = malloc( size ); NtGdiExtGetObjectW( dc->hPen, size, elp ); obj_type = get_gdi_object_type(dc->hPen); @@ -1642,12 +1641,12 @@ static struct gdi_path *PATH_WidenPath(DC *dc) break; default: SetLastError(ERROR_CAN_NOT_COMPLETE); - HeapFree( GetProcessHeap(), 0, elp ); + free( elp ); return NULL; } penWidth = elp->elpWidth; - HeapFree( GetProcessHeap(), 0, elp ); + free( elp ); endcap = (PS_ENDCAP_MASK & penStyle); joint = (PS_JOIN_MASK & penStyle); @@ -1682,10 +1681,7 @@ static struct gdi_path *PATH_WidenPath(DC *dc) case PT_MOVETO: numStrokes++; j = 0; - if(numStrokes == 1) - pStrokes = HeapAlloc(GetProcessHeap(), 0, sizeof(*pStrokes)); - else - pStrokes = HeapReAlloc(GetProcessHeap(), 0, pStrokes, numStrokes * sizeof(*pStrokes)); + pStrokes = realloc( pStrokes, numStrokes * sizeof(*pStrokes) ); if(!pStrokes) { free_gdi_path(flat_path); @@ -1706,7 +1702,7 @@ static struct gdi_path *PATH_WidenPath(DC *dc) default: ERR("Got path flag %c\n", flat_path->flags[i]); for(i = 0; i < numStrokes; i++) free_gdi_path(pStrokes[i]); - HeapFree(GetProcessHeap(), 0, pStrokes); + free( pStrokes ); free_gdi_path(flat_path); return NULL; } @@ -1897,7 +1893,7 @@ static struct gdi_path *PATH_WidenPath(DC *dc) free_gdi_path( pUpPath ); free_gdi_path( pDownPath ); } - HeapFree(GetProcessHeap(), 0, pStrokes); + free( pStrokes ); free_gdi_path( flat_path ); return pNewPath; } diff --git a/dlls/gdi32/pen.c b/dlls/gdi32/pen.c index 960cdc940f1..a6a14163827 100644 --- a/dlls/gdi32/pen.c +++ b/dlls/gdi32/pen.c @@ -78,7 +78,7 @@ HPEN create_pen( INT style, INT width, COLORREF color ) return 0; } - if (!(penPtr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*penPtr) ))) return 0; + if (!(penPtr = calloc( 1, sizeof(*penPtr) ))) return 0; penPtr->logpen.elpPenStyle = style; penPtr->logpen.elpWidth = abs(width); @@ -86,7 +86,7 @@ HPEN create_pen( INT style, INT width, COLORREF color ) penPtr->logpen.elpBrushStyle = BS_SOLID; if (!(hpen = alloc_gdi_handle( &penPtr->obj, NTGDI_OBJ_PEN, &pen_funcs ))) - HeapFree( GetProcessHeap(), 0, penPtr ); + free( penPtr ); return hpen; } @@ -170,7 +170,7 @@ HPEN WINAPI NtGdiExtCreatePen( DWORD style, DWORD width, ULONG brush_style, ULON if (brush_style != BS_SOLID) goto invalid; } - if (!(penPtr = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(PENOBJ,logpen.elpStyleEntry[style_count])))) + if (!(penPtr = malloc( FIELD_OFFSET(PENOBJ,logpen.elpStyleEntry[style_count]) ))) return 0; logbrush.lbStyle = brush_style; @@ -190,12 +190,12 @@ HPEN WINAPI NtGdiExtCreatePen( DWORD style, DWORD width, ULONG brush_style, ULON if (!(hpen = alloc_gdi_handle( &penPtr->obj, NTGDI_OBJ_EXTPEN, &pen_funcs ))) { free_brush_pattern( &penPtr->pattern ); - HeapFree( GetProcessHeap(), 0, penPtr ); + free( penPtr ); } return hpen; invalid: - HeapFree( GetProcessHeap(), 0, penPtr ); + free( penPtr ); SetLastError( ERROR_INVALID_PARAMETER ); return 0; } @@ -260,7 +260,7 @@ static BOOL PEN_DeleteObject( HGDIOBJ handle ) if (!pen) return FALSE; free_brush_pattern( &pen->pattern ); - HeapFree( GetProcessHeap(), 0, pen ); + free( pen ); return TRUE; } diff --git a/dlls/gdi32/region.c b/dlls/gdi32/region.c index 355743a665c..8555be96f72 100644 --- a/dlls/gdi32/region.c +++ b/dlls/gdi32/region.c @@ -135,13 +135,13 @@ static BOOL grow_region( WINEREGION *rgn, int size ) if (rgn->rects == rgn->rects_buf) { - new_rects = HeapAlloc( GetProcessHeap(), 0, size * sizeof(RECT) ); + new_rects = malloc( size * sizeof(RECT) ); if (!new_rects) return FALSE; memcpy( new_rects, rgn->rects, rgn->numRects * sizeof(RECT) ); } else { - new_rects = HeapReAlloc( GetProcessHeap(), 0, rgn->rects, size * sizeof(RECT) ); + new_rects = realloc( rgn->rects, size * sizeof(RECT) ); if (!new_rects) return FALSE; } rgn->rects = new_rects; @@ -413,7 +413,7 @@ static BOOL init_region( WINEREGION *pReg, INT n ) if (n > RGN_DEFAULT_RECTS) { if (n > INT_MAX / sizeof(RECT)) return FALSE; - if (!(pReg->rects = HeapAlloc( GetProcessHeap(), 0, n * sizeof( RECT ) ))) + if (!(pReg->rects = malloc( n * sizeof( RECT ) ))) return FALSE; } else @@ -430,7 +430,7 @@ static BOOL init_region( WINEREGION *pReg, INT n ) static void destroy_region( WINEREGION *pReg ) { if (pReg->rects != pReg->rects_buf) - HeapFree( GetProcessHeap(), 0, pReg->rects ); + free( pReg->rects ); } /*********************************************************************** @@ -439,7 +439,7 @@ static void destroy_region( WINEREGION *pReg ) static void free_region( WINEREGION *rgn ) { destroy_region( rgn ); - HeapFree( GetProcessHeap(), 0, rgn ); + free( rgn ); } /*********************************************************************** @@ -447,7 +447,7 @@ static void free_region( WINEREGION *rgn ) */ static WINEREGION *alloc_region( INT n ) { - WINEREGION *rgn = HeapAlloc( GetProcessHeap(), 0, sizeof(*rgn) ); + WINEREGION *rgn = malloc( sizeof(*rgn) ); if (rgn && !init_region( rgn, n )) { @@ -1537,7 +1537,7 @@ static void REGION_compact( WINEREGION *reg ) { if ((reg->numRects < reg->size / 2) && (reg->numRects > RGN_DEFAULT_RECTS)) { - RECT *new_rects = HeapReAlloc( GetProcessHeap(), 0, reg->rects, reg->numRects * sizeof(RECT) ); + RECT *new_rects = realloc( reg->rects, reg->numRects * sizeof(RECT) ); if (new_rects) { reg->rects = new_rects; @@ -2266,7 +2266,7 @@ static void REGION_InsertEdgeInET(EdgeTable *ET, EdgeTableEntry *ETE, { if (*iSLLBlock > SLLSPERBLOCK-1) { - tmpSLLBlock = HeapAlloc( GetProcessHeap(), 0, sizeof(ScanLineListBlock)); + tmpSLLBlock = malloc( sizeof(ScanLineListBlock) ); if(!tmpSLLBlock) { WARN("Can't alloc SLLB\n"); @@ -2512,7 +2512,7 @@ static void REGION_FreeStorage(ScanLineListBlock *pSLLBlock) while (pSLLBlock) { tmpSLLBlock = pSLLBlock->next; - HeapFree( GetProcessHeap(), 0, pSLLBlock ); + free( pSLLBlock ); pSLLBlock = tmpSLLBlock; } } @@ -2673,7 +2673,7 @@ HRGN create_polypolygon_region( const POINT *Pts, const INT *Count, INT nbpolygo for(poly = total = 0; poly < nbpolygons; poly++) total += Count[poly]; - if (! (pETEs = HeapAlloc( GetProcessHeap(), 0, sizeof(EdgeTableEntry) * total ))) + if (! (pETEs = malloc( sizeof(EdgeTableEntry) * total ))) return 0; nb_points = REGION_CreateEdgeTable( Count, nbpolygons, Pts, &ET, pETEs, &SLLBlock, clip_rect ); @@ -2686,6 +2686,6 @@ HRGN create_polypolygon_region( const POINT *Pts, const INT *Count, INT nbpolygo } REGION_FreeStorage(SLLBlock.next); - HeapFree( GetProcessHeap(), 0, pETEs ); + free( pETEs ); return hrgn; } diff --git a/dlls/gdi32/win32u_private.h b/dlls/gdi32/win32u_private.h index 3dc7ac656ef..836d8014f01 100644 --- a/dlls/gdi32/win32u_private.h +++ b/dlls/gdi32/win32u_private.h @@ -395,9 +395,6 @@ static inline LONG win32u_wcstol( LPCWSTR s, LPWSTR *end, INT base ) #define wcsrchr(s,c) win32u_wcsrchr(s,c) #define wcstol(s,e,b) win32u_wcstol(s,e,b) -#define HeapAlloc RtlAllocateHeap -#define HeapFree RtlFreeHeap -#define HeapReAlloc RtlReAllocateHeap #define EnterCriticalSection RtlEnterCriticalSection #define LeaveCriticalSection RtlLeaveCriticalSection