diff --git a/dlls/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c index 963fde035da..550c5f06f37 100644 --- a/dlls/winex11.drv/bitblt.c +++ b/dlls/winex11.drv/bitblt.c @@ -926,7 +926,7 @@ BOOL CDECL X11DRV_StretchBlt( PHYSDEV dst_dev, struct bitblt_coords *dst, static void CDECL free_heap_bits( struct gdi_image_bits *bits ) { - HeapFree( GetProcessHeap(), 0, bits->ptr ); + free( bits->ptr ); } static void CDECL free_ximage_bits( struct gdi_image_bits *bits ) @@ -1188,7 +1188,7 @@ DWORD copy_image_bits( BITMAPINFO *info, BOOL is_r8g8b8, XImage *image, { width_bytes = (width_bytes + 3) & ~3; info->bmiHeader.biSizeImage = height * width_bytes; - if (!(dst_bits->ptr = HeapAlloc( GetProcessHeap(), 0, info->bmiHeader.biSizeImage ))) + if (!(dst_bits->ptr = malloc( info->bmiHeader.biSizeImage ))) return ERROR_OUTOFMEMORY; dst_bits->is_copy = TRUE; dst_bits->free = free_heap_bits; @@ -1748,7 +1748,7 @@ static void update_surface_region( struct x11drv_window_surface *surface ) { XShapeCombineRectangles( gdi_display, surface->window, ShapeBounding, 0, 0, (XRectangle *)data->Buffer, data->rdh.nCount, ShapeSet, YXBanded ); - HeapFree( GetProcessHeap(), 0, data ); + free( data ); } NtGdiDeleteObjectApp( rgn ); @@ -1890,7 +1890,7 @@ static void x11drv_surface_set_region( struct window_surface *window_surface, HR { XSetClipRectangles( gdi_display, surface->gc, 0, 0, (XRectangle *)data->Buffer, data->rdh.nCount, YXBanded ); - HeapFree( GetProcessHeap(), 0, data ); + free( data ); } } window_surface->funcs->unlock( window_surface ); @@ -1974,7 +1974,7 @@ static void x11drv_surface_destroy( struct window_surface *window_surface ) if (surface->gc) XFreeGC( gdi_display, surface->gc ); if (surface->image) { - if (surface->image->data != surface->bits) HeapFree( GetProcessHeap(), 0, surface->bits ); + if (surface->image->data != surface->bits) free( surface->bits ); #ifdef HAVE_LIBXXSHM if (surface->shminfo.shmid != -1) { @@ -1983,12 +1983,12 @@ static void x11drv_surface_destroy( struct window_surface *window_surface ) } else #endif - HeapFree( GetProcessHeap(), 0, surface->image->data ); + free( surface->image->data ); surface->image->data = NULL; XDestroyImage( surface->image ); } if (surface->region) NtGdiDeleteObjectApp( surface->region ); - HeapFree( GetProcessHeap(), 0, surface ); + free( surface ); } static const struct window_surface_funcs x11drv_surface_funcs = @@ -2013,8 +2013,7 @@ struct window_surface *create_surface( Window window, const XVisualInfo *vis, co int width = rect->right - rect->left, height = rect->bottom - rect->top; int colors = format->bits_per_pixel <= 8 ? 1 << format->bits_per_pixel : 3; - surface = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, - FIELD_OFFSET( struct x11drv_window_surface, info.bmiColors[colors] )); + surface = calloc( 1, FIELD_OFFSET( struct x11drv_window_surface, info.bmiColors[colors] )); if (!surface) return NULL; surface->info.bmiHeader.biSize = sizeof(surface->info.bmiHeader); surface->info.bmiHeader.biWidth = width; @@ -2042,7 +2041,7 @@ struct window_surface *create_surface( Window window, const XVisualInfo *vis, co surface->image = XCreateImage( gdi_display, vis->visual, vis->depth, ZPixmap, 0, NULL, width, height, 32, 0 ); if (!surface->image) goto failed; - surface->image->data = HeapAlloc( GetProcessHeap(), 0, surface->info.bmiHeader.biSizeImage ); + surface->image->data = malloc( surface->info.bmiHeader.biSizeImage ); if (!surface->image->data) goto failed; } @@ -2056,8 +2055,7 @@ struct window_surface *create_surface( Window window, const XVisualInfo *vis, co if (surface->byteswap || format->bits_per_pixel == 4 || format->bits_per_pixel == 8) { /* allocate separate surface bits if byte swapping or palette mapping is required */ - if (!(surface->bits = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, - surface->info.bmiHeader.biSizeImage ))) + if (!(surface->bits = calloc( 1, surface->info.bmiHeader.biSizeImage ))) goto failed; } else surface->bits = surface->image->data; diff --git a/dlls/winex11.drv/brush.c b/dlls/winex11.drv/brush.c index 095df3ecc41..1ade09bd4be 100644 --- a/dlls/winex11.drv/brush.c +++ b/dlls/winex11.drv/brush.c @@ -122,8 +122,7 @@ static Pixmap BRUSH_DitherColor( COLORREF color, int depth) XUnlockDisplay( gdi_display ); return 0; } - ditherImage->data = HeapAlloc( GetProcessHeap(), 0, - ditherImage->height * ditherImage->bytes_per_line ); + ditherImage->data = malloc( ditherImage->height * ditherImage->bytes_per_line ); } if (color != prevColor) diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c index 8fdfb87a671..ddcaddec66f 100644 --- a/dlls/winex11.drv/clipboard.c +++ b/dlls/winex11.drv/clipboard.c @@ -291,7 +291,7 @@ static void register_builtin_formats(void) struct clipboard_format *formats; unsigned int i; - if (!(formats = HeapAlloc( GetProcessHeap(), 0, ARRAY_SIZE(builtin_formats) * sizeof(*formats)))) return; + if (!(formats = malloc( ARRAY_SIZE(builtin_formats) * sizeof(*formats)))) return; for (i = 0; i < ARRAY_SIZE(builtin_formats); i++) { @@ -316,7 +316,7 @@ static void register_formats( const UINT *ids, const Atom *atoms, unsigned int c struct clipboard_format *formats; unsigned int i; - if (!(formats = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*formats)))) return; + if (!(formats = malloc( count * sizeof(*formats)))) return; for (i = 0; i < count; i++) { @@ -352,7 +352,7 @@ static void register_win32_formats( const UINT *ids, UINT size ) if (find_win32_format( *ids )) continue; /* it already exists */ if (!GetClipboardFormatNameW( *ids, buffer, 256 )) continue; /* not a named format */ if (!(len = WideCharToMultiByte( CP_UNIXCP, 0, buffer, -1, NULL, 0, NULL, NULL ))) continue; - if (!(names[count] = HeapAlloc( GetProcessHeap(), 0, len ))) continue; + if (!(names[count] = malloc( len ))) continue; WideCharToMultiByte( CP_UNIXCP, 0, buffer, -1, names[count], len, NULL, NULL ); new_ids[count++] = *ids; } @@ -360,7 +360,7 @@ static void register_win32_formats( const UINT *ids, UINT size ) XInternAtoms( thread_display(), names, count, False, atoms ); register_formats( new_ids, atoms, count ); - while (count) HeapFree( GetProcessHeap(), 0, names[--count] ); + while (count) free( names[--count] ); } } @@ -580,7 +580,7 @@ static WCHAR* uri_to_dos(char *encodedURI) WCHAR *ret = NULL; int i; int j = 0; - char *uri = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, strlen(encodedURI) + 1); + char *uri = calloc( 1, strlen(encodedURI) + 1 ); if (uri == NULL) return NULL; for (i = 0; encodedURI[i]; ++i) @@ -601,7 +601,7 @@ static WCHAR* uri_to_dos(char *encodedURI) else { WARN("invalid URI encoding in %s\n", debugstr_a(encodedURI)); - HeapFree(GetProcessHeap(), 0, uri); + free( uri ); return NULL; } } @@ -649,7 +649,7 @@ static WCHAR* uri_to_dos(char *encodedURI) ret = wine_get_dos_file_name(&uri[5]); } } - HeapFree(GetProcessHeap(), 0, uri); + free( uri ); return ret; } @@ -865,7 +865,7 @@ static HANDLE import_text_html( Atom type, const void *data, size_t size ) { len = WideCharToMultiByte( CP_UTF8, 0, (const WCHAR *)data + 1, size / sizeof(WCHAR) - 1, NULL, 0, NULL, NULL ); - if (!(text = HeapAlloc( GetProcessHeap(), 0, len ))) return 0; + if (!(text = malloc( len ))) return 0; WideCharToMultiByte( CP_UTF8, 0, (const WCHAR *)data + 1, size / sizeof(WCHAR) - 1, text, len, NULL, NULL ); size = len; @@ -882,7 +882,7 @@ static HANDLE import_text_html( Atom type, const void *data, size_t size ) strcpy( p + size, trailer ); TRACE( "returning %s\n", debugstr_a( ret )); } - HeapFree( GetProcessHeap(), 0, text ); + free( text ); return ret; } @@ -904,7 +904,7 @@ static HANDLE import_text_uri_list( Atom type, const void *data, size_t size ) int end = 0; DROPFILES *dropFiles = NULL; - if (!(out = HeapAlloc(GetProcessHeap(), 0, capacity * sizeof(WCHAR)))) return 0; + if (!(out = malloc( capacity * sizeof(WCHAR) ))) return 0; while (end < size) { @@ -916,28 +916,30 @@ static HANDLE import_text_uri_list( Atom type, const void *data, size_t size ) break; } - uri = HeapAlloc(GetProcessHeap(), 0, end - start + 1); + uri = malloc( end - start + 1 ); if (uri == NULL) break; lstrcpynA(uri, &uriList[start], end - start + 1); path = uri_to_dos(uri); TRACE("converted URI %s to DOS path %s\n", debugstr_a(uri), debugstr_w(path)); - HeapFree(GetProcessHeap(), 0, uri); + HeapFree( GetProcessHeap(), 0, uri ); if (path) { int pathSize = strlenW(path) + 1; if (pathSize > capacity - total) { + WCHAR *new_out; capacity = 2*capacity + pathSize; - out = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, out, (capacity + 1)*sizeof(WCHAR)); - if (out == NULL) + new_out = realloc( out, (capacity + 1) * sizeof(WCHAR) ); + if (!new_out) goto done; + out = new_out; } memcpy(&out[total], path, pathSize * sizeof(WCHAR)); total += pathSize; done: - HeapFree(GetProcessHeap(), 0, path); + free( path ); if (out == NULL) break; } @@ -958,7 +960,7 @@ static HANDLE import_text_uri_list( Atom type, const void *data, size_t size ) memcpy( (char*)dropFiles + dropFiles->pFiles, out, (total + 1) * sizeof(WCHAR) ); } } - HeapFree(GetProcessHeap(), 0, out); + free( out ); return dropFiles; } @@ -979,7 +981,7 @@ static HANDLE import_targets( Atom type, const void *data, size_t size ) register_x11_formats( properties, count ); /* the builtin formats contain duplicates, so allocate some extra space */ - if (!(formats = HeapAlloc( GetProcessHeap(), 0, (count + ARRAY_SIZE(builtin_formats)) * sizeof(*formats )))) + if (!(formats = malloc( (count + ARRAY_SIZE(builtin_formats)) * sizeof(*formats )))) return 0; pos = 0; @@ -997,7 +999,7 @@ static HANDLE import_targets( Atom type, const void *data, size_t size ) else TRACE( "property %s (ignoring)\n", debugstr_xatom( properties[i] )); } - HeapFree( GetProcessHeap(), 0, current_x11_formats ); + free( current_x11_formats ); current_x11_formats = formats; nb_current_x11_formats = pos; return (HANDLE)1; @@ -1039,7 +1041,7 @@ static HANDLE import_selection( Display *display, Window win, Atom selection, return 0; } ret = format->import( type, data, size ); - HeapFree( GetProcessHeap(), 0, data ); + free( data ); return ret; } @@ -1121,7 +1123,7 @@ static char *string_from_unicode_text( UINT codepage, HANDLE handle, UINT *size UINT lenW = GlobalSize( handle ) / sizeof(WCHAR); DWORD len = WideCharToMultiByte( codepage, 0, strW, lenW, NULL, 0, NULL, NULL ); - if ((str = HeapAlloc( GetProcessHeap(), 0, len ))) + if ((str = malloc( len ))) { WideCharToMultiByte( codepage, 0, strW, lenW, str, len, NULL, NULL); GlobalUnlock( handle ); @@ -1153,7 +1155,7 @@ static BOOL export_string( Display *display, Window win, Atom prop, Atom target, if (!text) return FALSE; put_property( display, win, prop, target, 8, text, size ); - HeapFree( GetProcessHeap(), 0, text ); + free( text ); GlobalUnlock( handle ); return TRUE; } @@ -1171,7 +1173,7 @@ static BOOL export_utf8_string( Display *display, Window win, Atom prop, Atom ta if (!text) return FALSE; put_property( display, win, prop, target, 8, text, size ); - HeapFree( GetProcessHeap(), 0, text ); + free( text ); GlobalUnlock( handle ); return TRUE; } @@ -1213,7 +1215,7 @@ static BOOL export_compound_text( Display *display, Window win, Atom prop, Atom XFree( textprop.value ); } - HeapFree( GetProcessHeap(), 0, text ); + free( text ); return TRUE; } @@ -1254,7 +1256,7 @@ static BOOL export_image_bmp( Display *display, Window win, Atom prop, Atom targ BITMAPFILEHEADER *bfh; bmpsize = sizeof(BITMAPFILEHEADER) + GlobalSize( handle ); - bfh = HeapAlloc( GetProcessHeap(), 0, bmpsize ); + bfh = malloc( bmpsize ); if (bfh) { /* bitmap file header */ @@ -1269,7 +1271,7 @@ static BOOL export_image_bmp( Display *display, Window win, Atom prop, Atom targ } GlobalUnlock( handle ); put_property( display, win, prop, target, 8, bfh, bmpsize ); - HeapFree( GetProcessHeap(), 0, bfh ); + free( bfh ); return TRUE; } @@ -1285,11 +1287,11 @@ static BOOL export_enhmetafile( Display *display, Window win, Atom prop, Atom ta void *ptr; if (!(size = GetEnhMetaFileBits( handle, 0, NULL ))) return FALSE; - if (!(ptr = HeapAlloc( GetProcessHeap(), 0, size ))) return FALSE; + if (!(ptr = malloc( size ))) return FALSE; GetEnhMetaFileBits( handle, size, ptr ); put_property( display, win, prop, target, 8, ptr, size ); - HeapFree( GetProcessHeap(), 0, ptr ); + free( ptr ); return TRUE; } @@ -1340,7 +1342,7 @@ static BOOL export_hdrop( Display *display, Window win, Atom prop, Atom target, UINT textUriListSize = 32; UINT next = 0; - textUriList = HeapAlloc( GetProcessHeap(), 0, textUriListSize ); + textUriList = malloc( textUriListSize ); if (!textUriList) return FALSE; numFiles = DragQueryFileW( handle, 0xFFFFFFFF, NULL, 0 ); for (i = 0; i < numFiles; i++) @@ -1352,11 +1354,11 @@ static BOOL export_hdrop( Display *display, Window win, Atom prop, Atom target, UINT u; dosFilenameSize = 1 + DragQueryFileW( handle, i, NULL, 0 ); - dosFilename = HeapAlloc(GetProcessHeap(), 0, dosFilenameSize*sizeof(WCHAR)); + dosFilename = malloc( dosFilenameSize * sizeof(WCHAR) ); if (dosFilename == NULL) goto failed; DragQueryFileW( handle, i, dosFilename, dosFilenameSize ); unixFilename = wine_get_unix_file_name(dosFilename); - HeapFree(GetProcessHeap(), 0, dosFilename); + free( dosFilename ); if (unixFilename == NULL) goto failed; uriSize = 8 + /* file:/// */ 3 * (lstrlenA(unixFilename) - 1) + /* "%xy" per char except first '/' */ @@ -1364,7 +1366,7 @@ static BOOL export_hdrop( Display *display, Window win, Atom prop, Atom target, if ((next + uriSize) > textUriListSize) { UINT biggerSize = max( 2 * textUriListSize, next + uriSize ); - void *bigger = HeapReAlloc( GetProcessHeap(), 0, textUriList, biggerSize ); + void *bigger = realloc( textUriList, biggerSize ); if (bigger) { textUriList = bigger; @@ -1391,11 +1393,11 @@ static BOOL export_hdrop( Display *display, Window win, Atom prop, Atom target, HeapFree(GetProcessHeap(), 0, unixFilename); } put_property( display, win, prop, target, 8, textUriList, next ); - HeapFree( GetProcessHeap(), 0, textUriList ); + free( textUriList ); return TRUE; failed: - HeapFree( GetProcessHeap(), 0, textUriList ); + free( textUriList ); return FALSE; } @@ -1413,9 +1415,9 @@ static UINT *get_clipboard_formats( UINT *size ) *size = 256; for (;;) { - if (!(ids = HeapAlloc( GetProcessHeap(), 0, *size * sizeof(*ids) ))) return NULL; + if (!(ids = malloc( *size * sizeof(*ids) ))) return NULL; if (GetUpdatedClipboardFormats( ids, *size, size )) break; - HeapFree( GetProcessHeap(), 0, ids ); + free( ids ); if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return NULL; } register_win32_formats( ids, *size ); @@ -1450,10 +1452,9 @@ static BOOL export_targets( Display *display, Window win, Atom prop, Atom target if (!(formats = get_clipboard_formats( &count ))) return FALSE; /* the builtin formats contain duplicates, so allocate some extra space */ - if (!(targets = HeapAlloc( GetProcessHeap(), 0, - (count + ARRAY_SIZE(builtin_formats)) * sizeof(*targets) ))) + if (!(targets = malloc( (count + ARRAY_SIZE(builtin_formats)) * sizeof(*targets) ))) { - HeapFree( GetProcessHeap(), 0, formats ); + free( formats ); return FALSE; } @@ -1468,8 +1469,8 @@ static BOOL export_targets( Display *display, Window win, Atom prop, Atom target } put_property( display, win, prop, XA_ATOM, 32, targets, pos ); - HeapFree( GetProcessHeap(), 0, targets ); - HeapFree( GetProcessHeap(), 0, formats ); + free( targets ); + free( formats ); return TRUE; } @@ -1600,18 +1601,17 @@ static BOOL X11DRV_CLIPBOARD_GetProperty(Display *display, Window w, Atom prop, AnyPropertyType, atype, &aformat, &nitems, &remain, &buffer)) { WARN("Failed to read property\n"); - HeapFree( GetProcessHeap(), 0, val ); + free( val ); return FALSE; } count = get_property_size( aformat, nitems ); - if (!val) *data = HeapAlloc( GetProcessHeap(), 0, pos * sizeof(int) + count + 1 ); - else *data = HeapReAlloc( GetProcessHeap(), 0, val, pos * sizeof(int) + count + 1 ); + *data = realloc( val, pos * sizeof(int) + count + 1 ); if (!*data) { XFree( buffer ); - HeapFree( GetProcessHeap(), 0, val ); + free( val ); return FALSE; } val = *data; @@ -1669,7 +1669,7 @@ static BOOL read_property( Display *display, Window w, Atom prop, struct clipboard_data_packet *packet, *packet2; BOOL res; - HeapFree(GetProcessHeap(), 0, *data); + free( *data ); *data = NULL; list_init(&packets); @@ -1702,15 +1702,15 @@ static BOOL read_property( Display *display, Window w, Atom prop, /* Retrieved entire data. */ if (prop_size == 0) { - HeapFree(GetProcessHeap(), 0, prop_data); + free( prop_data ); res = TRUE; break; } - packet = HeapAlloc(GetProcessHeap(), 0, sizeof(*packet)); + packet = malloc( sizeof(*packet) ); if (!packet) { - HeapFree(GetProcessHeap(), 0, prop_data); + free( prop_data ); res = FALSE; break; } @@ -1723,7 +1723,7 @@ static BOOL read_property( Display *display, Window w, Atom prop, if (res) { - buf = HeapAlloc(GetProcessHeap(), 0, bufsize + 1); + buf = malloc( bufsize + 1 ); if (buf) { unsigned long bytes_copied = 0; @@ -1742,8 +1742,8 @@ static BOOL read_property( Display *display, Window w, Atom prop, LIST_FOR_EACH_ENTRY_SAFE( packet, packet2, &packets, struct clipboard_data_packet, entry) { - HeapFree(GetProcessHeap(), 0, packet->data); - HeapFree(GetProcessHeap(), 0, packet); + free( packet->data ); + free( packet ); } return res; @@ -1848,7 +1848,7 @@ static BOOL request_selection_contents( Display *display, BOOL changed ) if (!changed || !OpenClipboard( clipboard_hwnd )) { - HeapFree( GetProcessHeap(), 0, data ); + free( data ); return FALSE; } @@ -1859,7 +1859,7 @@ static BOOL request_selection_contents( Display *display, BOOL changed ) if (format) format->import( type, data, size ); - HeapFree( GetProcessHeap(), 0, last_data ); + free( last_data ); last_selection = current_selection; last_owner = owner; last_format = format; diff --git a/dlls/winex11.drv/desktop.c b/dlls/winex11.drv/desktop.c index 30a86d3b5b9..f8c44549fc1 100644 --- a/dlls/winex11.drv/desktop.c +++ b/dlls/winex11.drv/desktop.c @@ -31,7 +31,6 @@ /* avoid conflict with field names in included win32 headers */ #undef Status #include "wine/debug.h" -#include "wine/heap.h" WINE_DEFAULT_DEBUG_CHANNEL(x11drv); @@ -123,7 +122,7 @@ static BOOL X11DRV_desktop_get_modes( ULONG_PTR id, DWORD flags, DEVMODEW **new_ screen_height = primary_rect.bottom - primary_rect.top; /* Allocate memory for modes in different color depths */ - if (!(modes = heap_calloc( (ARRAY_SIZE(screen_sizes) + 2) * DEPTH_COUNT, sizeof(*modes))) ) + if (!(modes = calloc( (ARRAY_SIZE(screen_sizes) + 2) * DEPTH_COUNT, sizeof(*modes))) ) { SetLastError( ERROR_NOT_ENOUGH_MEMORY ); return FALSE; @@ -161,7 +160,7 @@ static BOOL X11DRV_desktop_get_modes( ULONG_PTR id, DWORD flags, DEVMODEW **new_ static void X11DRV_desktop_free_modes( DEVMODEW *modes ) { - heap_free( modes ); + free( modes ); } static BOOL X11DRV_desktop_get_current_mode( ULONG_PTR id, DEVMODEW *mode ) @@ -209,7 +208,7 @@ static BOOL X11DRV_desktop_get_gpus( struct gdi_gpu **new_gpus, int *count ) static const WCHAR wine_adapterW[] = {'W','i','n','e',' ','A','d','a','p','t','e','r',0}; struct gdi_gpu *gpu; - gpu = heap_calloc( 1, sizeof(*gpu) ); + gpu = calloc( 1, sizeof(*gpu) ); if (!gpu) return FALSE; if (!get_host_primary_gpu( gpu )) @@ -225,7 +224,7 @@ static BOOL X11DRV_desktop_get_gpus( struct gdi_gpu **new_gpus, int *count ) static void X11DRV_desktop_free_gpus( struct gdi_gpu *gpus ) { - heap_free( gpus ); + free( gpus ); } /* TODO: Support multi-head virtual desktop */ @@ -233,7 +232,7 @@ static BOOL X11DRV_desktop_get_adapters( ULONG_PTR gpu_id, struct gdi_adapter ** { struct gdi_adapter *adapter; - adapter = heap_calloc( 1, sizeof(*adapter) ); + adapter = calloc( 1, sizeof(*adapter) ); if (!adapter) return FALSE; adapter->state_flags = DISPLAY_DEVICE_PRIMARY_DEVICE; @@ -247,7 +246,7 @@ static BOOL X11DRV_desktop_get_adapters( ULONG_PTR gpu_id, struct gdi_adapter ** static void X11DRV_desktop_free_adapters( struct gdi_adapter *adapters ) { - heap_free( adapters ); + free( adapters ); } static BOOL X11DRV_desktop_get_monitors( ULONG_PTR adapter_id, struct gdi_monitor **new_monitors, int *count ) @@ -257,7 +256,7 @@ static BOOL X11DRV_desktop_get_monitors( ULONG_PTR adapter_id, struct gdi_monito 'N','o','n','-','P','n','P',' ','M','o','n','i','t','o','r',0}; struct gdi_monitor *monitor; - monitor = heap_calloc( 1, sizeof(*monitor) ); + monitor = calloc( 1, sizeof(*monitor) ); if (!monitor) return FALSE; lstrcpyW( monitor->name, generic_nonpnp_monitorW ); @@ -277,7 +276,7 @@ static BOOL X11DRV_desktop_get_monitors( ULONG_PTR adapter_id, struct gdi_monito static void X11DRV_desktop_free_monitors( struct gdi_monitor *monitors, int count ) { - heap_free( monitors ); + free( monitors ); } /*********************************************************************** diff --git a/dlls/winex11.drv/graphics.c b/dlls/winex11.drv/graphics.c index 715afcb8f6a..7ab358c43c1 100644 --- a/dlls/winex11.drv/graphics.c +++ b/dlls/winex11.drv/graphics.c @@ -148,8 +148,7 @@ static void add_pen_device_bounds( X11DRV_PDEVICE *dev, const POINT *points, int * X11DRV_GetRegionData * * Calls GetRegionData on the given region and converts the rectangle - * array to XRectangle format. The returned buffer must be freed by - * caller using HeapFree(GetProcessHeap(),...). + * array to XRectangle format. The returned buffer must be freed by caller. * If hdc_lptodp is not 0, the rectangles are converted through LPtoDP. */ RGNDATA *X11DRV_GetRegionData( HRGN hrgn, HDC hdc_lptodp ) @@ -167,10 +166,10 @@ RGNDATA *X11DRV_GetRegionData( HRGN hrgn, HDC hdc_lptodp ) int count = (size - sizeof(RGNDATAHEADER)) / sizeof(RECT); size += count * (sizeof(XRectangle) - sizeof(RECT)); } - if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return NULL; + if (!(data = malloc( size ))) return NULL; if (!NtGdiGetRegionData( hrgn, size, data )) { - HeapFree( GetProcessHeap(), 0, data ); + free( data ); return NULL; } @@ -256,7 +255,7 @@ static void update_x11_clipping( X11DRV_PDEVICE *physDev, HRGN rgn ) { XSetClipRectangles( gdi_display, physDev->gc, physDev->dc_rect.left, physDev->dc_rect.top, (XRectangle *)data->Buffer, data->rdh.nCount, YXBanded ); - HeapFree( GetProcessHeap(), 0, data ); + free( data ); } } @@ -1079,7 +1078,7 @@ BOOL CDECL X11DRV_PaintRgn( PHYSDEV dev, HRGN hrgn ) } XFillRectangles( gdi_display, physDev->drawable, physDev->gc, rect, data->rdh.nCount ); - HeapFree( GetProcessHeap(), 0, data ); + free( data ); } if (NtGdiGetRgnBox( hrgn, &rc )) { @@ -1099,15 +1098,15 @@ static BOOL X11DRV_Polygon( PHYSDEV dev, const POINT* pt, INT count ) POINT *points; XPoint *xpoints; - points = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*pt) ); + points = malloc( count * sizeof(*pt) ); if (!points) return FALSE; memcpy( points, pt, count * sizeof(*pt) ); lp_to_dp( dev->hdc, points, count ); add_pen_device_bounds( physDev, points, count ); - if (!(xpoints = HeapAlloc( GetProcessHeap(), 0, sizeof(XPoint) * (count+1) ))) + if (!(xpoints = malloc( sizeof(XPoint) * (count+1) ))) { - HeapFree( GetProcessHeap(), 0, points ); + free( points ); return FALSE; } for (i = 0; i < count; i++) @@ -1125,8 +1124,8 @@ static BOOL X11DRV_Polygon( PHYSDEV dev, const POINT* pt, INT count ) XDrawLines( gdi_display, physDev->drawable, physDev->gc, xpoints, count+1, CoordModeOrigin ); - HeapFree( GetProcessHeap(), 0, xpoints ); - HeapFree( GetProcessHeap(), 0, points ); + free( xpoints ); + free( points ); return TRUE; } @@ -1150,7 +1149,7 @@ BOOL CDECL X11DRV_PolyPolygon( PHYSDEV dev, const POINT* pt, const INT* counts, total += counts[i]; } - points = HeapAlloc( GetProcessHeap(), 0, total * sizeof(*pt) ); + points = malloc( total * sizeof(*pt) ); if (!points) return FALSE; memcpy( points, pt, total * sizeof(*pt) ); lp_to_dp( dev->hdc, points, total ); @@ -1178,7 +1177,7 @@ BOOL CDECL X11DRV_PolyPolygon( PHYSDEV dev, const POINT* pt, const INT* counts, } XFillRectangles( gdi_display, physDev->drawable, physDev->gc, rect, data->rdh.nCount ); - HeapFree( GetProcessHeap(), 0, data ); + free( data ); } if (X11DRV_SetupGCForPen ( physDev )) @@ -1186,7 +1185,7 @@ BOOL CDECL X11DRV_PolyPolygon( PHYSDEV dev, const POINT* pt, const INT* counts, XPoint *xpoints; int j; - if (!(xpoints = HeapAlloc( GetProcessHeap(), 0, sizeof(XPoint) * (max + 1) ))) goto done; + if (!(xpoints = malloc( sizeof(XPoint) * (max + 1) ))) goto done; for (i = pos = 0; i < polygons; pos += counts[i++]) { for (j = 0; j < counts[i]; j++) @@ -1197,12 +1196,12 @@ BOOL CDECL X11DRV_PolyPolygon( PHYSDEV dev, const POINT* pt, const INT* counts, xpoints[j] = xpoints[0]; XDrawLines( gdi_display, physDev->drawable, physDev->gc, xpoints, j + 1, CoordModeOrigin ); } - HeapFree( GetProcessHeap(), 0, xpoints ); + free( xpoints ); } ret = TRUE; done: - HeapFree( GetProcessHeap(), 0, points ); + free( points ); return ret; } @@ -1223,7 +1222,7 @@ BOOL CDECL X11DRV_PolyPolyline( PHYSDEV dev, const POINT* pt, const DWORD* count total += counts[i]; } - points = HeapAlloc( GetProcessHeap(), 0, total * sizeof(*pt) ); + points = malloc( total * sizeof(*pt) ); if (!points) return FALSE; memcpy( points, pt, total * sizeof(*pt) ); lp_to_dp( dev->hdc, points, total ); @@ -1233,9 +1232,9 @@ BOOL CDECL X11DRV_PolyPolyline( PHYSDEV dev, const POINT* pt, const DWORD* count { XPoint *xpoints; - if (!(xpoints = HeapAlloc( GetProcessHeap(), 0, sizeof(XPoint) * max ))) + if (!(xpoints = malloc( sizeof(XPoint) * max ))) { - HeapFree( GetProcessHeap(), 0, points ); + free( points ); return FALSE; } for (i = pos = 0; i < polylines; pos += counts[i++]) @@ -1247,9 +1246,9 @@ BOOL CDECL X11DRV_PolyPolyline( PHYSDEV dev, const POINT* pt, const DWORD* count } XDrawLines( gdi_display, physDev->drawable, physDev->gc, xpoints, j, CoordModeOrigin ); } - HeapFree( GetProcessHeap(), 0, xpoints ); + free( xpoints ); } - HeapFree( GetProcessHeap(), 0, points ); + free( points ); return TRUE; } @@ -1270,9 +1269,9 @@ static BOOL x11drv_stroke_and_fill_path( PHYSDEV dev, BOOL stroke, BOOL fill ) NtGdiAbortPath( dev->hdc ); return TRUE; } - xpoints = HeapAlloc( GetProcessHeap(), 0, (size + 1) * sizeof(*xpoints) ); - points = HeapAlloc( GetProcessHeap(), 0, size * sizeof(*points) ); - flags = HeapAlloc( GetProcessHeap(), 0, size * sizeof(*flags) ); + xpoints = malloc( (size + 1) * sizeof(*xpoints) ); + points = malloc( size * sizeof(*points) ); + flags = malloc( size * sizeof(*flags) ); if (!points || !flags || !xpoints) goto done; if (NtGdiGetPath( dev->hdc, points, flags, size ) == -1) goto done; lp_to_dp( dev->hdc, points, size ); @@ -1293,7 +1292,7 @@ static BOOL x11drv_stroke_and_fill_path( PHYSDEV dev, BOOL stroke, BOOL fill ) } XFillRectangles( gdi_display, physDev->drawable, physDev->gc, rect, data->rdh.nCount ); - HeapFree( GetProcessHeap(), 0, data ); + free( data ); } if (stroke && X11DRV_SetupGCForPen ( physDev )) @@ -1324,9 +1323,9 @@ static BOOL x11drv_stroke_and_fill_path( PHYSDEV dev, BOOL stroke, BOOL fill ) ret = TRUE; done: - HeapFree( GetProcessHeap(), 0, xpoints ); - HeapFree( GetProcessHeap(), 0, points ); - HeapFree( GetProcessHeap(), 0, flags ); + free( xpoints ); + free( points ); + free( flags ); return ret; } @@ -1635,7 +1634,7 @@ static char *get_icm_profile( unsigned long *size ) *size = get_property_size( format, count ); if (format && count) { - if ((ret = HeapAlloc( GetProcessHeap(), 0, *size ))) memcpy( ret, profile, *size ); + if ((ret = malloc( *size ))) memcpy( ret, profile, *size ); XFree( profile ); } return ret; @@ -1724,7 +1723,7 @@ BOOL CDECL X11DRV_GetICMProfile( PHYSDEV dev, BOOL allow_default, LPDWORD size, if (status) ERR( "Unable to write color profile: %x\n", status ); NtClose( file ); } - HeapFree( GetProcessHeap(), 0, buffer ); + free( buffer ); } else if (!allow_default) return FALSE; else lstrcpyW( p, srgb ); diff --git a/dlls/winex11.drv/init.c b/dlls/winex11.drv/init.c index 88d09145f8e..9c5c394581b 100644 --- a/dlls/winex11.drv/init.c +++ b/dlls/winex11.drv/init.c @@ -79,7 +79,7 @@ static X11DRV_PDEVICE *create_x11_physdev( Drawable drawable ) pthread_once( &init_once, device_init ); - if (!(physDev = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*physDev) ))) return NULL; + if (!(physDev = calloc( 1, sizeof(*physDev) ))) return NULL; physDev->drawable = drawable; physDev->gc = XCreateGC( gdi_display, drawable, 0, NULL ); @@ -135,7 +135,7 @@ static BOOL CDECL X11DRV_DeleteDC( PHYSDEV dev ) X11DRV_PDEVICE *physDev = get_x11drv_dev( dev ); XFreeGC( gdi_display, physDev->gc ); - HeapFree( GetProcessHeap(), 0, physDev ); + free( physDev ); return TRUE; } diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c index 170231c0026..fac97ef7e35 100644 --- a/dlls/winex11.drv/keyboard.c +++ b/dlls/winex11.drv/keyboard.c @@ -1338,7 +1338,7 @@ BOOL X11DRV_KeyEvent( HWND hwnd, XEvent *xev ) TRACE_(key)("XmbLookupString needs %i byte(s)\n", ascii_chars); if (status == XBufferOverflow) { - Str = HeapAlloc(GetProcessHeap(), 0, ascii_chars); + Str = malloc( ascii_chars ); if (Str == NULL) { ERR_(key)("Failed to allocate memory!\n"); @@ -1356,7 +1356,7 @@ BOOL X11DRV_KeyEvent( HWND hwnd, XEvent *xev ) { X11DRV_XIMLookupChars( Str, ascii_chars ); if (buf != Str) - HeapFree(GetProcessHeap(), 0, Str); + free( Str ); return TRUE; } @@ -1385,7 +1385,7 @@ BOOL X11DRV_KeyEvent( HWND hwnd, XEvent *xev ) keysym, ksname, ascii_chars, debugstr_an(Str, ascii_chars)); } if (buf != Str) - HeapFree(GetProcessHeap(), 0, Str); + free( Str ); vkey = EVENT_event_to_vkey(xic,event); /* X returns keycode 0 for composed characters */ @@ -2463,7 +2463,7 @@ INT X11DRV_ToUnicodeEx( UINT virtKey, UINT scanCode, const BYTE *lpKeyState, TRACE_(key)("XmbLookupString needs %d byte(s)\n", ret); if (status == XBufferOverflow) { - lpChar = HeapAlloc(GetProcessHeap(), 0, ret); + lpChar = malloc( ret ); if (lpChar == NULL) { ERR_(key)("Failed to allocate memory!\n"); @@ -2617,7 +2617,7 @@ INT X11DRV_ToUnicodeEx( UINT virtKey, UINT scanCode, const BYTE *lpKeyState, found: if (buf != lpChar) - HeapFree(GetProcessHeap(), 0, lpChar); + free( lpChar ); pthread_mutex_unlock( &kbd_mutex ); diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c index 5bebcf42fb2..d87cff079ec 100644 --- a/dlls/winex11.drv/mouse.c +++ b/dlls/winex11.drv/mouse.c @@ -791,10 +791,10 @@ static Cursor create_xcursor_cursor( HDC hdc, const ICONINFOEXW *iinfo, HANDLE i /* Retrieve the number of frames to render */ if (!NtUserGetCursorFrameInfo(icon, 0, &delay_jiffies, &nFrames)) return 0; - if (!(imgs = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(XcursorImage*)*nFrames ))) return 0; + if (!(imgs = calloc( 1, sizeof(XcursorImage*) * nFrames ))) return 0; /* Allocate all of the resources necessary to obtain a cursor frame */ - if (!(info = HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET( BITMAPINFO, bmiColors[256] )))) goto cleanup; + if (!(info = malloc( FIELD_OFFSET( BITMAPINFO, bmiColors[256] )))) goto cleanup; info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); info->bmiHeader.biWidth = width; info->bmiHeader.biHeight = -height; @@ -848,7 +848,7 @@ static Cursor create_xcursor_cursor( HDC hdc, const ICONINFOEXW *iinfo, HANDLE i images->images[images->nimage] = imgs[images->nimage]; cursor = pXcursorImagesLoadCursor( gdi_display, images ); pXcursorImagesDestroy( images ); /* Note: this frees each individual frame (calls XcursorImageDestroy) */ - HeapFree( GetProcessHeap(), 0, imgs ); + free( imgs ); imgs = NULL; cleanup: @@ -857,12 +857,12 @@ cleanup: /* Failed to produce a cursor, free previously allocated frames */ for (i=0; ibmiHeader.biClrUsed = 0; info->bmiHeader.biClrImportant = 0; - if (!(mask_bits = HeapAlloc( GetProcessHeap(), 0, info->bmiHeader.biSizeImage ))) goto done; + if (!(mask_bits = malloc( info->bmiHeader.biSizeImage ))) goto done; if (!NtGdiGetDIBitsInternal( hdc, icon->hbmMask, 0, height * 2, mask_bits, info, DIB_RGB_COLORS, 0, 0 )) goto done; @@ -1220,7 +1220,7 @@ static Cursor create_xlib_monochrome_cursor( HDC hdc, const ICONINFOEXW *icon, i XFreePixmap( gdi_display, mask_pixmap ); done: - HeapFree( GetProcessHeap(), 0, mask_bits ); + free( mask_bits ); return cursor; } @@ -1294,14 +1294,14 @@ static Cursor create_xlib_color_cursor( HDC hdc, const ICONINFOEXW *icon, int wi info->bmiHeader.biClrUsed = 0; info->bmiHeader.biClrImportant = 0; - if (!(mask_bits = HeapAlloc( GetProcessHeap(), 0, info->bmiHeader.biSizeImage ))) goto done; + if (!(mask_bits = malloc( info->bmiHeader.biSizeImage ))) goto done; if (!NtGdiGetDIBitsInternal( hdc, icon->hbmMask, 0, height, mask_bits, info, DIB_RGB_COLORS, 0, 0 )) goto done; info->bmiHeader.biBitCount = 32; info->bmiHeader.biSizeImage = width * height * 4; - if (!(color_bits = HeapAlloc( GetProcessHeap(), 0, info->bmiHeader.biSizeImage ))) goto done; - if (!(xor_bits = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, width_bytes * height ))) goto done; + if (!(color_bits = malloc( info->bmiHeader.biSizeImage ))) goto done; + if (!(xor_bits = calloc( 1, width_bytes * height ))) goto done; NtGdiGetDIBitsInternal( hdc, icon->hbmColor, 0, height, color_bits, info, DIB_RGB_COLORS, 0, 0 ); /* compute fg/bg color and xor bitmap based on average of the color values */ @@ -1389,9 +1389,9 @@ static Cursor create_xlib_color_cursor( HDC hdc, const ICONINFOEXW *icon, int wi XFreePixmap( gdi_display, xor_pixmap ); done: - HeapFree( GetProcessHeap(), 0, color_bits ); - HeapFree( GetProcessHeap(), 0, xor_bits ); - HeapFree( GetProcessHeap(), 0, mask_bits ); + free( color_bits ); + free( xor_bits ); + free( mask_bits ); return cursor; } diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 00dd06e0a8b..92555841f71 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -37,7 +37,6 @@ #include "x11drv.h" #include "xcomposite.h" #include "winternl.h" -#include "wine/heap.h" #include "wine/debug.h" #ifdef SONAME_LIBGL @@ -467,7 +466,7 @@ static BOOL X11DRV_WineGL_InitOpenglInfo(void) gl_renderer = (const char *)opengl_funcs.gl.p_glGetString(GL_RENDERER); gl_version = (const char *)opengl_funcs.gl.p_glGetString(GL_VERSION); str = (const char *) opengl_funcs.gl.p_glGetString(GL_EXTENSIONS); - glExtensions = HeapAlloc(GetProcessHeap(), 0, strlen(str)+sizeof(legacy_extensions)); + glExtensions = malloc( strlen(str) + sizeof(legacy_extensions) ); strcpy(glExtensions, str); strcat(glExtensions, legacy_extensions); @@ -1023,7 +1022,7 @@ static void init_pixel_formats( Display *display ) } TRACE("Found %d bitmap capable fbconfigs\n", bmp_formats); - list = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (nCfgs + bmp_formats) * sizeof(*list)); + list = calloc( 1, (nCfgs + bmp_formats) * sizeof(*list) ); /* Fill the pixel format list. Put onscreen formats at the top and offscreen ones at the bottom. * Do this as GLX doesn't guarantee that the list is sorted */ @@ -1165,7 +1164,7 @@ static void release_gl_drawable( struct gl_drawable *gl ) default: break; } - HeapFree( GetProcessHeap(), 0, gl ); + free( gl ); } /* Mark any allocated context using the glx drawable 'old' to use 'new' */ @@ -1308,7 +1307,7 @@ static struct gl_drawable *create_gl_drawable( HWND hwnd, const struct wgl_pixel width = min( max( 1, rect.right ), 65535 ); height = min( max( 1, rect.bottom ), 65535 ); - if (!(gl = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*gl) ))) return NULL; + if (!(gl = calloc( 1, sizeof(*gl) ))) return NULL; /* Default GLX and WGL swap interval is 1, but in case of glXSwapIntervalSGI * there is no way to query it, so we have to store it here. @@ -1358,7 +1357,7 @@ static struct gl_drawable *create_gl_drawable( HWND hwnd, const struct wgl_pixel if (!gl->drawable) { - HeapFree( GetProcessHeap(), 0, gl ); + free( gl ); return NULL; } @@ -1724,7 +1723,7 @@ static struct wgl_context * WINAPI glxdrv_wglCreateContext( HDC hdc ) return NULL; } - if ((ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ret)))) + if ((ret = calloc( 1, sizeof(*ret) ))) { ret->hdc = hdc; ret->fmt = gl->format; @@ -1763,7 +1762,8 @@ static BOOL WINAPI glxdrv_wglDeleteContext(struct wgl_context *ctx) release_gl_drawable( ctx->drawables[1] ); release_gl_drawable( ctx->new_drawables[0] ); release_gl_drawable( ctx->new_drawables[1] ); - return HeapFree( GetProcessHeap(), 0, ctx ); + free( ctx ); + return TRUE; } /*********************************************************************** @@ -2011,7 +2011,7 @@ static struct wgl_context *X11DRV_wglCreateContextAttribsARB( HDC hdc, struct wg return NULL; } - if ((ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ret)))) + if ((ret = calloc( 1, sizeof(*ret) ))) { ret->hdc = hdc; ret->fmt = gl->format; @@ -2077,7 +2077,7 @@ static struct wgl_context *X11DRV_wglCreateContextAttribsARB( HDC hdc, struct wg { /* In the future we should convert the GLX error to a win32 one here if needed */ WARN("Context creation failed (error %#x).\n", err); - HeapFree( GetProcessHeap(), 0, ret ); + free( ret ); ret = NULL; } else @@ -2127,7 +2127,7 @@ static struct wgl_pbuffer *X11DRV_wglCreatePbufferARB( HDC hdc, int iPixelFormat return NULL; } - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); + object = calloc( 1, sizeof(*object) ); if (NULL == object) { SetLastError(ERROR_NO_SYSTEM_RESOURCES); return NULL; @@ -2285,7 +2285,7 @@ static struct wgl_pbuffer *X11DRV_wglCreatePbufferARB( HDC hdc, int iPixelFormat return object; create_failed: - HeapFree(GetProcessHeap(), 0, object); + free( object ); TRACE("->(FAILED)\n"); return NULL; } @@ -2305,7 +2305,7 @@ static BOOL X11DRV_wglDestroyPbufferARB( struct wgl_pbuffer *object ) pglXDestroyPbuffer(gdi_display, object->drawable); if (object->tmp_context) pglXDestroyContext(gdi_display, object->tmp_context); - HeapFree(GetProcessHeap(), 0, object); + free( object ); return GL_TRUE; } @@ -2323,7 +2323,7 @@ static HDC X11DRV_wglGetPbufferDCARB( struct wgl_pbuffer *object ) hdc = NtGdiOpenDCW( NULL, NULL, NULL, 0, TRUE, NULL, NULL, NULL ); if (!hdc) return 0; - if (!(gl = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*gl) ))) + if (!(gl = calloc( 1, sizeof(*gl) ))) { NtGdiDeleteObjectApp( hdc ); return 0; @@ -2589,7 +2589,7 @@ static BOOL X11DRV_wglChoosePixelFormatARB( HDC hdc, const int *piAttribIList, c return GL_FALSE; } - if (!(formats = heap_alloc(nCfgs * sizeof(*formats)))) + if (!(formats = malloc( nCfgs * sizeof(*formats) ))) { ERR("No memory.\n"); XFree(cfgs); @@ -2639,7 +2639,7 @@ static BOOL X11DRV_wglChoosePixelFormatARB( HDC hdc, const int *piAttribIList, c for (i = 0; i < *nNumFormats; ++i) piFormats[i] = formats[i].format; - heap_free(formats); + free( formats ); XFree(cfgs); return GL_TRUE; } @@ -2923,7 +2923,7 @@ static BOOL X11DRV_wglGetPixelFormatAttribfvARB( HDC hdc, int iPixelFormat, int TRACE("(%p, %d, %d, %d, %p, %p)\n", hdc, iPixelFormat, iLayerPlane, nAttributes, piAttributes, pfValues); /* Allocate a temporary array to store integer values */ - attr = HeapAlloc(GetProcessHeap(), 0, nAttributes * sizeof(int)); + attr = malloc( nAttributes * sizeof(int) ); if (!attr) { ERR("couldn't allocate %d array\n", nAttributes); return GL_FALSE; @@ -2939,7 +2939,7 @@ static BOOL X11DRV_wglGetPixelFormatAttribfvARB( HDC hdc, int iPixelFormat, int } } - HeapFree(GetProcessHeap(), 0, attr); + free( attr ); return ret; } diff --git a/dlls/winex11.drv/palette.c b/dlls/winex11.drv/palette.c index ae4bf38d934..475466999b1 100644 --- a/dlls/winex11.drv/palette.c +++ b/dlls/winex11.drv/palette.c @@ -332,7 +332,7 @@ int X11DRV_PALETTE_Init(void) { get_palette_entries( GetStockObject(DEFAULT_PALETTE), 0, NB_RESERVED_COLORS, sys_pal_template ); - if ((mapping = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(int) * NB_RESERVED_COLORS ))) + if ((mapping = calloc( 1, sizeof(int) * NB_RESERVED_COLORS ))) palette_set_mapping( GetStockObject(DEFAULT_PALETTE), mapping ); if (X11DRV_PALETTE_PaletteFlags & X11DRV_PALETTE_PRIVATE) @@ -364,7 +364,8 @@ static BOOL X11DRV_PALETTE_BuildPrivateMap( const PALETTEENTRY *sys_pal_template XColor color; int i; - if((COLOR_sysPal = HeapAlloc(GetProcessHeap(), 0, sizeof(PALETTEENTRY)*palette_size)) == NULL) { + if((COLOR_sysPal = malloc( sizeof(PALETTEENTRY) * palette_size )) == NULL) + { WARN("Unable to allocate the system palette\n"); return FALSE; } @@ -526,7 +527,8 @@ static BOOL X11DRV_PALETTE_BuildSharedMap( const PALETTEENTRY *sys_pal_template * X guidelines and does binary search... */ - if((pixDynMapping = HeapAlloc(GetProcessHeap(), 0, sizeof(long)*palette_size)) == NULL) { + if (!(pixDynMapping = malloc( sizeof(*pixDynMapping) * palette_size ))) + { WARN("Out of memory while building system palette.\n"); return FALSE; } @@ -594,10 +596,10 @@ static BOOL X11DRV_PALETTE_BuildSharedMap( const PALETTEENTRY *sys_pal_template (X11DRV_PALETTE_PaletteFlags & X11DRV_PALETTE_VIRTUAL || !(X11DRV_PALETTE_PaletteFlags & X11DRV_PALETTE_FIXED)) ) ? NB_RESERVED_COLORS/2 : -1; - COLOR_sysPal = HeapAlloc(GetProcessHeap(),0,sizeof(PALETTEENTRY)*256); + COLOR_sysPal = malloc( sizeof(PALETTEENTRY) * 256 ); if(COLOR_sysPal == NULL) { ERR("Unable to allocate the system palette!\n"); - HeapFree(GetProcessHeap(), 0, pixDynMapping); + free( pixDynMapping ); return FALSE; } @@ -605,10 +607,10 @@ static BOOL X11DRV_PALETTE_BuildSharedMap( const PALETTEENTRY *sys_pal_template if (default_visual.depth <= 8) { - X11DRV_PALETTE_XPixelToPalette = HeapAlloc( GetProcessHeap(), 0, 256 * sizeof(int) ); + X11DRV_PALETTE_XPixelToPalette = malloc( 256 * sizeof(int) ); if(X11DRV_PALETTE_XPixelToPalette == NULL) { ERR("Out of memory: XPixelToPalette!\n"); - HeapFree(GetProcessHeap(), 0, pixDynMapping); + free( pixDynMapping ); return FALSE; } for( i = 0; i < 256; i++ ) @@ -619,10 +621,10 @@ static BOOL X11DRV_PALETTE_BuildSharedMap( const PALETTEENTRY *sys_pal_template * RGB->pixel calculation in X11DRV_PALETTE_ToPhysical(). */ - X11DRV_PALETTE_PaletteToXPixel = HeapAlloc(GetProcessHeap(),0,sizeof(int)*256); + X11DRV_PALETTE_PaletteToXPixel = malloc( sizeof(int) * 256 ); if(X11DRV_PALETTE_PaletteToXPixel == NULL) { ERR("Out of memory: PaletteToXPixel!\n"); - HeapFree(GetProcessHeap(), 0, pixDynMapping); + free( pixDynMapping ); return FALSE; } @@ -658,7 +660,7 @@ static BOOL X11DRV_PALETTE_BuildSharedMap( const PALETTEENTRY *sys_pal_template X11DRV_PALETTE_XPixelToPalette[X11DRV_PALETTE_PaletteToXPixel[i]] = i; } - HeapFree(GetProcessHeap(), 0, pixDynMapping); + free( pixDynMapping ); return TRUE; } @@ -1194,10 +1196,7 @@ UINT CDECL X11DRV_RealizePalette( PHYSDEV dev, HPALETTE hpal, BOOL primary ) /* initialize palette mapping table */ prev_mapping = palette_get_mapping( hpal ); - if (prev_mapping) - mapping = HeapReAlloc( GetProcessHeap(), 0, prev_mapping, sizeof(int)*num_entries); - else - mapping = HeapAlloc( GetProcessHeap(), 0, sizeof(int)*num_entries); + mapping = realloc( prev_mapping, sizeof(int) * num_entries ); if(mapping == NULL) { ERR("Unable to allocate new mapping -- memory exhausted!\n"); @@ -1302,7 +1301,7 @@ BOOL CDECL X11DRV_UnrealizePalette( HPALETTE hpal ) if (mapping) { XDeleteContext( gdi_display, (XID)hpal, palette_context ); - HeapFree( GetProcessHeap(), 0, mapping ); + free( mapping ); } return TRUE; } diff --git a/dlls/winex11.drv/pen.c b/dlls/winex11.drv/pen.c index 620e57aae3c..ffa628ce6f7 100644 --- a/dlls/winex11.drv/pen.c +++ b/dlls/winex11.drv/pen.c @@ -78,7 +78,7 @@ HPEN CDECL X11DRV_SelectPen( PHYSDEV dev, HPEN hpen, const struct brush_pattern if (!size) return 0; physDev->pen.ext = 1; - elp = HeapAlloc( GetProcessHeap(), 0, size ); + elp = malloc( size ); NtGdiExtGetObjectW( hpen, size, elp ); logpen.lopnStyle = elp->elpPenStyle; @@ -145,7 +145,7 @@ HPEN CDECL X11DRV_SelectPen( PHYSDEV dev, HPEN hpen, const struct brush_pattern for(i = 0; i < physDev->pen.dash_len; i++) physDev->pen.dashes[i] = min( physDev->pen.dashes[i] * physDev->pen.width, 255 ); - HeapFree( GetProcessHeap(), 0, elp ); + free( elp ); return hpen; } diff --git a/dlls/winex11.drv/settings.c b/dlls/winex11.drv/settings.c index dd1d2a54024..652dedce601 100644 --- a/dlls/winex11.drv/settings.c +++ b/dlls/winex11.drv/settings.c @@ -31,7 +31,6 @@ #include "winreg.h" #include "wingdi.h" #include "wine/debug.h" -#include "wine/heap.h" #include "wine/unicode.h" WINE_DEFAULT_DEBUG_CHANNEL(x11settings); @@ -101,7 +100,7 @@ static BOOL nores_get_modes(ULONG_PTR id, DWORD flags, DEVMODEW **new_modes, UIN RECT primary = get_host_primary_monitor_rect(); DEVMODEW *modes; - modes = heap_calloc(1, sizeof(*modes)); + modes = calloc(1, sizeof(*modes)); if (!modes) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); @@ -126,7 +125,7 @@ static BOOL nores_get_modes(ULONG_PTR id, DWORD flags, DEVMODEW **new_modes, UIN static void nores_free_modes(DEVMODEW *modes) { - heap_free(modes); + free(modes); } static BOOL nores_get_current_mode(ULONG_PTR id, DEVMODEW *mode) @@ -431,7 +430,7 @@ static void set_display_depth(ULONG_PTR display_id, DWORD depth) } } - display_depth = heap_alloc(sizeof(*display_depth)); + display_depth = malloc(sizeof(*display_depth)); if (!display_depth) { ERR("Failed to allocate memory.\n"); @@ -595,7 +594,7 @@ static DEVMODEW *get_full_mode(ULONG_PTR id, DEVMODEW *dev_mode) return NULL; } - if (!(full_mode = heap_alloc(sizeof(*found_mode) + found_mode->dmDriverExtra))) + if (!(full_mode = malloc(sizeof(*found_mode) + found_mode->dmDriverExtra))) { handler.free_modes(modes); return NULL; @@ -612,7 +611,7 @@ static DEVMODEW *get_full_mode(ULONG_PTR id, DEVMODEW *dev_mode) static void free_full_mode(DEVMODEW *mode) { if (!is_detached_mode(mode)) - heap_free(mode); + free(mode); } static LONG get_display_settings(struct x11drv_display_setting **new_displays, @@ -629,7 +628,7 @@ static LONG get_display_settings(struct x11drv_display_setting **new_displays, for (display_idx = 0; !NtUserEnumDisplayDevices( NULL, display_idx, &display_device, 0 ); ++display_idx) ++display_count; - displays = heap_calloc(display_count, sizeof(*displays)); + displays = calloc(display_count, sizeof(*displays)); if (!displays) goto done; @@ -692,7 +691,7 @@ static LONG get_display_settings(struct x11drv_display_setting **new_displays, return DISP_CHANGE_SUCCESSFUL; done: - heap_free(displays); + free(displays); return ret; } @@ -956,7 +955,7 @@ LONG X11DRV_ChangeDisplaySettingsEx( LPCWSTR devname, LPDEVMODEW devmode, full_mode = get_full_mode(displays[display_idx].id, &displays[display_idx].desired_mode); if (!full_mode) { - heap_free(displays); + free(displays); return DISP_CHANGE_BADMODE; } @@ -964,7 +963,7 @@ LONG X11DRV_ChangeDisplaySettingsEx( LPCWSTR devname, LPDEVMODEW devmode, { ERR("Failed to write %s display settings to registry.\n", wine_dbgstr_w(devname)); free_full_mode(full_mode); - heap_free(displays); + free(displays); return DISP_CHANGE_NOTUPDATED; } @@ -976,14 +975,14 @@ LONG X11DRV_ChangeDisplaySettingsEx( LPCWSTR devname, LPDEVMODEW devmode, if (flags & (CDS_TEST | CDS_NORESET)) { - heap_free(displays); + free(displays); return DISP_CHANGE_SUCCESSFUL; } if (all_detached_settings(displays, display_count)) { WARN("Detaching all displays is not permitted.\n"); - heap_free(displays); + free(displays); return DISP_CHANGE_SUCCESSFUL; } @@ -995,6 +994,6 @@ LONG X11DRV_ChangeDisplaySettingsEx( LPCWSTR devname, LPDEVMODEW devmode, ret = apply_display_settings(displays, display_count, TRUE); if (ret == DISP_CHANGE_SUCCESSFUL) X11DRV_DisplayDevices_Update(TRUE); - heap_free(displays); + free(displays); return ret; } diff --git a/dlls/winex11.drv/vulkan.c b/dlls/winex11.drv/vulkan.c index f4fe202dfaf..29e0b10763a 100644 --- a/dlls/winex11.drv/vulkan.c +++ b/dlls/winex11.drv/vulkan.c @@ -30,7 +30,6 @@ #include "winbase.h" #include "wine/debug.h" -#include "wine/heap.h" #include "x11drv.h" #define VK_NO_PROTOTYPES @@ -165,7 +164,7 @@ static VkResult wine_vk_instance_convert_create_info(const VkInstanceCreateInfo if (src->enabledExtensionCount > 0) { - enabled_extensions = heap_calloc(src->enabledExtensionCount, sizeof(*src->ppEnabledExtensionNames)); + enabled_extensions = calloc(src->enabledExtensionCount, sizeof(*src->ppEnabledExtensionNames)); if (!enabled_extensions) { ERR("Failed to allocate memory for enabled extensions\n"); @@ -214,7 +213,7 @@ static void wine_vk_surface_release(struct wine_vk_surface *surface) if (surface->window) XDestroyWindow(gdi_display, surface->window); - heap_free(surface); + free(surface); } void wine_vk_surface_destroy(HWND hwnd) @@ -273,7 +272,7 @@ static VkResult X11DRV_vkCreateInstance(const VkInstanceCreateInfo *create_info, res = pvkCreateInstance(&create_info_host, NULL /* allocator */, instance); - heap_free((void *)create_info_host.ppEnabledExtensionNames); + free((void *)create_info_host.ppEnabledExtensionNames); return res; } @@ -317,7 +316,7 @@ static VkResult X11DRV_vkCreateWin32SurfaceKHR(VkInstance instance, return VK_ERROR_INCOMPATIBLE_DRIVER; } - x11_surface = heap_alloc_zero(sizeof(*x11_surface)); + x11_surface = calloc(1, sizeof(*x11_surface)); if (!x11_surface) return VK_ERROR_OUT_OF_HOST_MEMORY; @@ -578,7 +577,7 @@ static VkResult X11DRV_vkGetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice ph if (!formats) return pvkGetPhysicalDeviceSurfaceFormatsKHR(phys_dev, surface_info_host.surface, count, NULL); - formats_host = heap_calloc(*count, sizeof(*formats_host)); + formats_host = calloc(*count, sizeof(*formats_host)); if (!formats_host) return VK_ERROR_OUT_OF_HOST_MEMORY; result = pvkGetPhysicalDeviceSurfaceFormatsKHR(phys_dev, surface_info_host.surface, count, formats_host); if (result == VK_SUCCESS || result == VK_INCOMPLETE) @@ -587,7 +586,7 @@ static VkResult X11DRV_vkGetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice ph formats[i].surfaceFormat = formats_host[i]; } - heap_free(formats_host); + free(formats_host); return result; } diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 4cf771a998f..6771368671a 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -213,7 +213,7 @@ static struct x11drv_win_data *alloc_win_data( Display *display, HWND hwnd ) { struct x11drv_win_data *data; - if ((data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data)))) + if ((data = calloc( 1, sizeof(*data) ))) { data->display = display; data->vis = default_visual; @@ -405,7 +405,7 @@ static void sync_window_region( struct x11drv_win_data *data, HRGN win_region ) data->window_rect.top - data->whole_rect.top, (XRectangle *)pRegionData->Buffer, pRegionData->rdh.nCount, ShapeSet, YXBanded ); - HeapFree(GetProcessHeap(), 0, pRegionData); + free( pRegionData ); data->shaped = TRUE; } } @@ -443,13 +443,13 @@ static void sync_window_text( Display *display, Window win, const WCHAR *text ) /* allocate new buffer for window text */ count = WideCharToMultiByte(CP_UNIXCP, 0, text, -1, NULL, 0, NULL, NULL); - if (!(buffer = HeapAlloc( GetProcessHeap(), 0, count ))) return; + if (!(buffer = malloc( count ))) return; WideCharToMultiByte(CP_UNIXCP, 0, text, -1, buffer, count, NULL, NULL); count = WideCharToMultiByte(CP_UTF8, 0, text, strlenW(text), NULL, 0, NULL, NULL); - if (!(utf8_buffer = HeapAlloc( GetProcessHeap(), 0, count ))) + if (!(utf8_buffer = malloc( count ))) { - HeapFree( GetProcessHeap(), 0, buffer ); + free( buffer ); return; } WideCharToMultiByte(CP_UTF8, 0, text, strlenW(text), utf8_buffer, count, NULL, NULL); @@ -468,8 +468,8 @@ static void sync_window_text( Display *display, Window win, const WCHAR *text ) XChangeProperty( display, win, x11drv_atom(_NET_WM_NAME), x11drv_atom(UTF8_STRING), 8, PropModeReplace, (unsigned char *) utf8_buffer, count); - HeapFree( GetProcessHeap(), 0, utf8_buffer ); - HeapFree( GetProcessHeap(), 0, buffer ); + free( utf8_buffer ); + free( buffer ); } @@ -501,7 +501,7 @@ static unsigned long *get_bitmap_argb( HDC hdc, HBITMAP color, HBITMAP mask, uns info->bmiHeader.biClrUsed = 0; info->bmiHeader.biClrImportant = 0; *size = bm.bmWidth * bm.bmHeight + 2; - if (!(bits = HeapAlloc( GetProcessHeap(), 0, *size * sizeof(long) ))) goto failed; + if (!(bits = malloc( *size * sizeof(long) ))) goto failed; if (!NtGdiGetDIBitsInternal( hdc, color, 0, bm.bmHeight, bits + 2, info, DIB_RGB_COLORS, 0, 0 )) goto failed; @@ -517,14 +517,14 @@ static unsigned long *get_bitmap_argb( HDC hdc, HBITMAP color, HBITMAP mask, uns /* generate alpha channel from the mask */ info->bmiHeader.biBitCount = 1; info->bmiHeader.biSizeImage = width_bytes * bm.bmHeight; - if (!(mask_bits = HeapAlloc( GetProcessHeap(), 0, info->bmiHeader.biSizeImage ))) goto failed; + if (!(mask_bits = malloc( info->bmiHeader.biSizeImage ))) goto failed; if (!NtGdiGetDIBitsInternal( hdc, mask, 0, bm.bmHeight, mask_bits, info, DIB_RGB_COLORS, 0, 0 )) goto failed; ptr = bits + 2; for (i = 0; i < bm.bmHeight; i++) for (j = 0; j < bm.bmWidth; j++, ptr++) if (!((mask_bits[i * width_bytes + j / 8] << (j % 8)) & 0x80)) *ptr |= 0xff000000; - HeapFree( GetProcessHeap(), 0, mask_bits ); + free( mask_bits ); } /* convert to array of longs */ @@ -534,8 +534,8 @@ static unsigned long *get_bitmap_argb( HDC hdc, HBITMAP color, HBITMAP mask, uns return (unsigned long *)bits; failed: - HeapFree( GetProcessHeap(), 0, bits ); - HeapFree( GetProcessHeap(), 0, mask_bits ); + free( bits ); + free( mask_bits ); return NULL; } @@ -561,12 +561,12 @@ static BOOL create_icon_pixmaps( HDC hdc, const ICONINFO *icon, Pixmap *icon_ret info->bmiHeader.biBitCount = 0; if (!(lines = NtGdiGetDIBitsInternal( hdc, icon->hbmColor, 0, 0, NULL, info, DIB_RGB_COLORS, 0, 0 ))) goto failed; - if (!(bits.ptr = HeapAlloc( GetProcessHeap(), 0, info->bmiHeader.biSizeImage ))) goto failed; + if (!(bits.ptr = malloc( info->bmiHeader.biSizeImage ))) goto failed; if (!NtGdiGetDIBitsInternal( hdc, icon->hbmColor, 0, lines, bits.ptr, info, DIB_RGB_COLORS, 0, 0 )) goto failed; color_pixmap = create_pixmap_from_image( hdc, &vis, info, &bits, DIB_RGB_COLORS ); - HeapFree( GetProcessHeap(), 0, bits.ptr ); + free( bits.ptr ); bits.ptr = NULL; if (!color_pixmap) goto failed; @@ -574,7 +574,7 @@ static BOOL create_icon_pixmaps( HDC hdc, const ICONINFO *icon, Pixmap *icon_ret info->bmiHeader.biBitCount = 0; if (!(lines = NtGdiGetDIBitsInternal( hdc, icon->hbmMask, 0, 0, NULL, info, DIB_RGB_COLORS, 0, 0 ))) goto failed; - if (!(bits.ptr = HeapAlloc( GetProcessHeap(), 0, info->bmiHeader.biSizeImage ))) goto failed; + if (!(bits.ptr = malloc( info->bmiHeader.biSizeImage ))) goto failed; if (!NtGdiGetDIBitsInternal( hdc, icon->hbmMask, 0, lines, bits.ptr, info, DIB_RGB_COLORS, 0, 0 )) goto failed; @@ -583,7 +583,7 @@ static BOOL create_icon_pixmaps( HDC hdc, const ICONINFO *icon, Pixmap *icon_ret vis.depth = 1; mask_pixmap = create_pixmap_from_image( hdc, &vis, info, &bits, DIB_RGB_COLORS ); - HeapFree( GetProcessHeap(), 0, bits.ptr ); + free( bits.ptr ); bits.ptr = NULL; if (!mask_pixmap) goto failed; @@ -593,7 +593,7 @@ static BOOL create_icon_pixmaps( HDC hdc, const ICONINFO *icon, Pixmap *icon_ret failed: if (color_pixmap) XFreePixmap( gdi_display, color_pixmap ); - HeapFree( GetProcessHeap(), 0, bits.ptr ); + free( bits.ptr ); return FALSE; } @@ -642,15 +642,14 @@ static void fetch_icon_data( HWND hwnd, HICON icon_big, HICON icon_small ) if ((bits_small = get_bitmap_argb( hDC, ii_small.hbmColor, ii_small.hbmMask, &size_small )) && (bits_small[0] != bits[0] || bits_small[1] != bits[1])) /* size must be different */ { - if ((new = HeapReAlloc( GetProcessHeap(), 0, bits, - (size + size_small) * sizeof(unsigned long) ))) + if ((new = realloc( bits, (size + size_small) * sizeof(unsigned long) ))) { bits = new; memcpy( bits + size, bits_small, size_small * sizeof(unsigned long) ); size += size_small; } } - HeapFree( GetProcessHeap(), 0, bits_small ); + free( bits_small ); NtGdiDeleteObjectApp( ii_small.hbmColor ); NtGdiDeleteObjectApp( ii_small.hbmMask ); } @@ -665,7 +664,7 @@ static void fetch_icon_data( HWND hwnd, HICON icon_big, HICON icon_small ) { if (data->icon_pixmap) XFreePixmap( gdi_display, data->icon_pixmap ); if (data->icon_mask) XFreePixmap( gdi_display, data->icon_mask ); - HeapFree( GetProcessHeap(), 0, data->icon_bits ); + free( data->icon_bits ); data->icon_pixmap = icon_pixmap; data->icon_mask = mask_pixmap; data->icon_bits = bits; @@ -676,7 +675,7 @@ static void fetch_icon_data( HWND hwnd, HICON icon_big, HICON icon_small ) { if (icon_pixmap) XFreePixmap( gdi_display, icon_pixmap ); if (mask_pixmap) XFreePixmap( gdi_display, mask_pixmap ); - HeapFree( GetProcessHeap(), 0, bits ); + free( bits ); } } @@ -1759,10 +1758,10 @@ void X11DRV_DestroyWindow( HWND hwnd ) if (data->icon_pixmap) XFreePixmap( gdi_display, data->icon_pixmap ); if (data->icon_mask) XFreePixmap( gdi_display, data->icon_mask ); if (data->client_colormap) XFreeColormap( data->display, data->client_colormap ); - HeapFree( GetProcessHeap(), 0, data->icon_bits ); + free( data->icon_bits ); XDeleteContext( gdi_display, (XID)hwnd, win_data_context ); release_win_data( data ); - HeapFree( GetProcessHeap(), 0, data ); + free( data ); destroy_gl_drawable( hwnd ); wine_vk_surface_destroy( hwnd ); } diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c index 14ee13dc676..6042f2522b5 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -50,7 +50,6 @@ #include "wine/unicode.h" #include "wine/debug.h" #include "wine/list.h" -#include "wine/heap.h" WINE_DEFAULT_DEBUG_CHANNEL(x11drv); WINE_DECLARE_DEBUG_CHANNEL(synchronous); @@ -315,7 +314,7 @@ static void init_pixmap_formats( Display *display ) formats[i].depth, formats[i].bits_per_pixel, formats[i].scanline_pad ); if (formats[i].depth > max) max = formats[i].depth; } - pixmap_formats = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pixmap_formats) * (max + 1) ); + pixmap_formats = calloc( 1, sizeof(*pixmap_formats) * (max + 1) ); for (i = 0; i < count; i++) pixmap_formats[formats[i].depth] = &formats[i]; } @@ -442,7 +441,7 @@ static void setup_options(void) if ((p = strrchrW( appname, '\\' ))) appname = p + 1; CharLowerW(appname); len = WideCharToMultiByte( CP_UNIXCP, 0, appname, -1, NULL, 0, NULL, NULL ); - if ((process_name = HeapAlloc( GetProcessHeap(), 0, len ))) + if ((process_name = malloc( len ))) WideCharToMultiByte( CP_UNIXCP, 0, appname, -1, process_name, len, NULL, NULL ); strcatW( appname, x11driverW ); /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\X11 Driver */ @@ -707,7 +706,7 @@ void X11DRV_ThreadDetach(void) if (data->xim) XCloseIM( data->xim ); if (data->font_set) XFreeFontSet( data->display, data->font_set ); XCloseDisplay( data->display ); - HeapFree( GetProcessHeap(), 0, data ); + free( data ); /* clear data in case we get re-entered from user32 before the thread is truly dead */ NtUserGetThreadInfo()->driver_data = NULL; } @@ -749,7 +748,7 @@ struct x11drv_thread_data *x11drv_init_thread_data(void) if (data) return data; - if (!(data = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data) ))) + if (!(data = calloc( 1, sizeof(*data) ))) { ERR( "could not create data\n" ); ExitProcess(1); @@ -906,7 +905,7 @@ NTSTATUS CDECL X11DRV_D3DKMTSetVidPnSourceOwner( const D3DKMT_SETVIDPNSOURCEOWNE if (source->device == desc->hDevice) { list_remove( &source->entry ); - heap_free( source ); + free( source ); } } goto done; @@ -929,7 +928,7 @@ NTSTATUS CDECL X11DRV_D3DKMTSetVidPnSourceOwner( const D3DKMT_SETVIDPNSOURCEOWNE source->type = desc->pType[i]; else { - source = heap_alloc( sizeof( *source ) ); + source = malloc( sizeof( *source ) ); if (!source) { status = STATUS_NO_MEMORY; diff --git a/dlls/winex11.drv/xinerama.c b/dlls/winex11.drv/xinerama.c index b707574a0ab..a97590e705f 100644 --- a/dlls/winex11.drv/xinerama.c +++ b/dlls/winex11.drv/xinerama.c @@ -29,7 +29,6 @@ #include #include "x11drv.h" #include "wine/debug.h" -#include "wine/heap.h" WINE_DEFAULT_DEBUG_CHANNEL(x11drv); @@ -87,8 +86,8 @@ static int query_screens(void) !pXineramaQueryExtension( gdi_display, &event_base, &error_base ) || !(screens = pXineramaQueryScreens( gdi_display, &count ))) return 0; - if (monitors != &default_monitor) HeapFree( GetProcessHeap(), 0, monitors ); - if ((monitors = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*monitors) ))) + if (monitors != &default_monitor) free( monitors ); + if ((monitors = malloc( count * sizeof(*monitors) ))) { nb_monitors = count; for (i = 0; i < nb_monitors; i++) @@ -125,7 +124,7 @@ static BOOL xinerama_get_gpus( struct gdi_gpu **new_gpus, int *count ) struct gdi_gpu *gpus; /* Xinerama has no support for GPU, faking one */ - gpus = heap_calloc( 1, sizeof(*gpus) ); + gpus = calloc( 1, sizeof(*gpus) ); if (!gpus) return FALSE; @@ -139,7 +138,7 @@ static BOOL xinerama_get_gpus( struct gdi_gpu **new_gpus, int *count ) static void xinerama_free_gpus( struct gdi_gpu *gpus ) { - heap_free( gpus ); + free( gpus ); } static BOOL xinerama_get_adapters( ULONG_PTR gpu_id, struct gdi_adapter **new_adapters, int *count ) @@ -154,7 +153,7 @@ static BOOL xinerama_get_adapters( ULONG_PTR gpu_id, struct gdi_adapter **new_ad return FALSE; /* Being lazy, actual adapter count may be less */ - adapters = heap_calloc( nb_monitors, sizeof(*adapters) ); + adapters = calloc( nb_monitors, sizeof(*adapters) ); if (!adapters) return FALSE; @@ -206,7 +205,7 @@ static BOOL xinerama_get_adapters( ULONG_PTR gpu_id, struct gdi_adapter **new_ad static void xinerama_free_adapters( struct gdi_adapter *adapters ) { - heap_free( adapters ); + free( adapters ); } static BOOL xinerama_get_monitors( ULONG_PTR adapter_id, struct gdi_monitor **new_monitors, int *count ) @@ -228,7 +227,7 @@ static BOOL xinerama_get_monitors( ULONG_PTR adapter_id, struct gdi_monitor **ne monitor_count++; } - monitor = heap_calloc( monitor_count, sizeof(*monitor) ); + monitor = calloc( monitor_count, sizeof(*monitor) ); if (!monitor) return FALSE; @@ -259,7 +258,7 @@ static BOOL xinerama_get_monitors( ULONG_PTR adapter_id, struct gdi_monitor **ne static void xinerama_free_monitors( struct gdi_monitor *monitors, int count ) { - heap_free( monitors ); + free( monitors ); } void xinerama_init( unsigned int width, unsigned int height ) diff --git a/dlls/winex11.drv/xrandr.c b/dlls/winex11.drv/xrandr.c index e97034fcb2c..b0619c0abcd 100644 --- a/dlls/winex11.drv/xrandr.c +++ b/dlls/winex11.drv/xrandr.c @@ -43,7 +43,6 @@ WINE_DECLARE_DEBUG_CHANNEL(winediag); #define VK_NO_PROTOTYPES #define WINE_VK_HOST -#include "wine/heap.h" #include "wine/unicode.h" #include "wine/vulkan.h" #include "wine/vulkan_driver.h" @@ -199,7 +198,7 @@ static BOOL xrandr10_get_modes( ULONG_PTR id, DWORD flags, DEVMODEW **new_modes, /* Allocate space for reported modes in three depths, and put an SizeID at the end of DEVMODEW as * driver private data */ - modes = heap_calloc( mode_count * DEPTH_COUNT, sizeof(*modes) + sizeof(SizeID) ); + modes = calloc( mode_count * DEPTH_COUNT, sizeof(*modes) + sizeof(SizeID) ); if (!modes) { SetLastError( ERROR_NOT_ENOUGH_MEMORY ); @@ -235,7 +234,7 @@ static BOOL xrandr10_get_modes( ULONG_PTR id, DWORD flags, DEVMODEW **new_modes, static void xrandr10_free_modes( DEVMODEW *modes ) { - heap_free( modes ); + free( modes ); } static BOOL xrandr10_get_current_mode( ULONG_PTR id, DEVMODEW *mode ) @@ -339,7 +338,7 @@ static pthread_mutex_t xrandr_mutex = PTHREAD_MUTEX_INITIALIZER; static void xrandr14_invalidate_current_mode_cache(void) { pthread_mutex_lock( &xrandr_mutex ); - heap_free( current_modes); + free( current_modes); current_modes = NULL; current_mode_count = 0; pthread_mutex_unlock( &xrandr_mutex ); @@ -690,7 +689,7 @@ static BOOL get_gpu_properties_from_vulkan( struct gdi_gpu *gpu, const XRRProvid goto done; } - if (!(vk_physical_devices = heap_calloc( device_count, sizeof(*vk_physical_devices) ))) + if (!(vk_physical_devices = calloc( device_count, sizeof(*vk_physical_devices) ))) goto done; vr = pvkEnumeratePhysicalDevices( vk_instance, &device_count, vk_physical_devices ); @@ -731,7 +730,7 @@ static BOOL get_gpu_properties_from_vulkan( struct gdi_gpu *gpu, const XRRProvid } done: - heap_free( vk_physical_devices ); + free( vk_physical_devices ); if (vk_instance) vulkan_funcs->p_vkDestroyInstance( vk_instance, NULL ); return ret; @@ -760,7 +759,7 @@ static BOOL xrandr14_get_gpus2( struct gdi_gpu **new_gpus, int *count, BOOL get_ if (!provider_resources) goto done; - gpus = heap_calloc( provider_resources->nproviders ? provider_resources->nproviders : 1, sizeof(*gpus) ); + gpus = calloc( provider_resources->nproviders ? provider_resources->nproviders : 1, sizeof(*gpus) ); if (!gpus) goto done; @@ -828,7 +827,7 @@ done: pXRRFreeScreenResources( screen_resources ); if (!ret) { - heap_free( gpus ); + free( gpus ); ERR("Failed to get gpus\n"); } return ret; @@ -841,7 +840,7 @@ static BOOL xrandr14_get_gpus( struct gdi_gpu **new_gpus, int *count ) static void xrandr14_free_gpus( struct gdi_gpu *gpus ) { - heap_free( gpus ); + free( gpus ); } static BOOL xrandr14_get_adapters( ULONG_PTR gpu_id, struct gdi_adapter **new_adapters, int *count ) @@ -883,7 +882,7 @@ static BOOL xrandr14_get_adapters( ULONG_PTR gpu_id, struct gdi_adapter **new_ad } /* Actual adapter count could be less */ - adapters = heap_calloc( crtc_count, sizeof(*adapters) ); + adapters = calloc( crtc_count, sizeof(*adapters) ); if (!adapters) goto done; @@ -999,7 +998,7 @@ done: pXRRFreeCrtcInfo( crtc_info ); if (!ret) { - heap_free( adapters ); + free( adapters ); ERR("Failed to get adapters\n"); } return ret; @@ -1007,7 +1006,7 @@ done: static void xrandr14_free_adapters( struct gdi_adapter *adapters ) { - heap_free( adapters ); + free( adapters ); } static BOOL xrandr14_get_monitors( ULONG_PTR adapter_id, struct gdi_monitor **new_monitors, int *count ) @@ -1030,7 +1029,7 @@ static BOOL xrandr14_get_monitors( ULONG_PTR adapter_id, struct gdi_monitor **ne /* First start with a 2 monitors, should be enough for most cases */ capacity = 2; - monitors = heap_calloc( capacity, sizeof(*monitors) ); + monitors = calloc( capacity, sizeof(*monitors) ); if (!monitors) goto done; @@ -1076,7 +1075,7 @@ static BOOL xrandr14_get_monitors( ULONG_PTR adapter_id, struct gdi_monitor **ne if (monitor_count >= capacity) { capacity *= 2; - realloc_monitors = heap_realloc( monitors, capacity * sizeof(*monitors) ); + realloc_monitors = realloc( monitors, capacity * sizeof(*monitors) ); if (!realloc_monitors) goto done; monitors = realloc_monitors; @@ -1154,7 +1153,7 @@ done: if (monitors[i].edid) XFree( monitors[i].edid ); } - heap_free( monitors ); + free( monitors ); ERR("Failed to get monitors\n"); } return ret; @@ -1169,7 +1168,7 @@ static void xrandr14_free_monitors( struct gdi_monitor *monitors, int count ) if (monitors[i].edid) XFree( monitors[i].edid ); } - heap_free( monitors ); + free( monitors ); } static BOOL xrandr14_device_change_handler( HWND hwnd, XEvent *event ) @@ -1235,11 +1234,7 @@ static BOOL xrandr14_get_id( const WCHAR *device_name, ULONG_PTR *id ) if (!xrandr14_get_adapters( gpus[gpu_idx].id, &adapters, &adapter_count )) break; - if (!new_current_modes) - tmp_modes = heap_alloc( adapter_count * sizeof(*tmp_modes) ); - else - tmp_modes = heap_realloc( new_current_modes, (new_current_mode_count + adapter_count) * sizeof(*tmp_modes) ); - + tmp_modes = realloc( new_current_modes, (new_current_mode_count + adapter_count) * sizeof(*tmp_modes) ); if (!tmp_modes) { xrandr14_free_adapters( adapters ); @@ -1259,7 +1254,7 @@ static BOOL xrandr14_get_id( const WCHAR *device_name, ULONG_PTR *id ) if (new_current_modes) { - heap_free( current_modes ); + free( current_modes ); current_modes = new_current_modes; current_mode_count = new_current_mode_count; } @@ -1371,8 +1366,8 @@ static BOOL xrandr14_get_modes( ULONG_PTR id, DWORD flags, DEVMODEW **new_modes, /* Allocate space for display modes in different color depths and orientations. * Store a RRMode at the end of each DEVMODEW as private driver data */ - modes = heap_calloc( output_info->nmode * DEPTH_COUNT * orientation_count, - sizeof(*modes) + sizeof(RRMode) ); + modes = calloc( output_info->nmode * DEPTH_COUNT * orientation_count, + sizeof(*modes) + sizeof(RRMode) ); if (!modes) goto done; @@ -1418,7 +1413,7 @@ done: static void xrandr14_free_modes( DEVMODEW *modes ) { - heap_free( modes ); + free( modes ); } static BOOL xrandr14_get_current_mode( ULONG_PTR id, DEVMODEW *mode ) diff --git a/dlls/winex11.drv/xrender.c b/dlls/winex11.drv/xrender.c index be64da90290..2a694794397 100644 --- a/dlls/winex11.drv/xrender.c +++ b/dlls/winex11.drv/xrender.c @@ -362,8 +362,7 @@ const struct gdi_dc_funcs *X11DRV_XRender_Init(void) return NULL; } - glyphsetCache = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - sizeof(*glyphsetCache) * INIT_CACHE_SIZE); + glyphsetCache = calloc( sizeof(*glyphsetCache), INIT_CACHE_SIZE ); glyphsetCacheSize = INIT_CACHE_SIZE; lastfree = 0; @@ -471,7 +470,7 @@ static void update_xrender_clipping( struct xrender_physdev *dev, HRGN rgn ) pXRenderSetPictureClipRectangles( gdi_display, dev->pict, dev->x11dev->dc_rect.left, dev->x11dev->dc_rect.top, (XRectangle *)data->Buffer, data->rdh.nCount ); - HeapFree( GetProcessHeap(), 0, data ); + free( data ); } } @@ -630,14 +629,14 @@ static void FreeEntry(int entry) formatEntry->glyphset = 0; } if(formatEntry->nrealized) { - HeapFree(GetProcessHeap(), 0, formatEntry->realized); + free( formatEntry->realized ); formatEntry->realized = NULL; - HeapFree(GetProcessHeap(), 0, formatEntry->gis); + free( formatEntry->gis ); formatEntry->gis = NULL; formatEntry->nrealized = 0; } - HeapFree(GetProcessHeap(), 0, formatEntry); + free( formatEntry ); glyphsetCache[entry].format[type][format] = NULL; } } @@ -684,18 +683,12 @@ static int AllocEntry(void) TRACE("Growing cache\n"); - if (glyphsetCache) - glyphsetCache = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - glyphsetCache, - (glyphsetCacheSize + INIT_CACHE_SIZE) - * sizeof(*glyphsetCache)); - else - glyphsetCache = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - (glyphsetCacheSize + INIT_CACHE_SIZE) - * sizeof(*glyphsetCache)); + glyphsetCache = realloc( glyphsetCache, + (glyphsetCacheSize + INIT_CACHE_SIZE) * sizeof(*glyphsetCache) ); - for(best = i = glyphsetCacheSize; i < glyphsetCacheSize + INIT_CACHE_SIZE; - i++) { + for (best = i = glyphsetCacheSize; i < glyphsetCacheSize + INIT_CACHE_SIZE; i++) + { + memset( &glyphsetCache[i], 0, sizeof(glyphsetCache[i]) ); glyphsetCache[i].next = i + 1; glyphsetCache[i].count = -1; } @@ -891,7 +884,7 @@ static void set_physdev_format( struct xrender_physdev *physdev, enum wxr_format static BOOL create_xrender_dc( PHYSDEV *pdev, enum wxr_format format ) { X11DRV_PDEVICE *x11dev = get_x11drv_dev( *pdev ); - struct xrender_physdev *physdev = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*physdev) ); + struct xrender_physdev *physdev = calloc( 1, sizeof(*physdev) ); if (!physdev) return FALSE; physdev->x11dev = x11dev; @@ -967,7 +960,7 @@ static BOOL CDECL xrenderdrv_DeleteDC( PHYSDEV dev ) if (physdev->cache_index != -1) dec_ref_cache( physdev->cache_index ); pthread_mutex_unlock( &xrender_mutex ); - HeapFree( GetProcessHeap(), 0, physdev ); + free( physdev ); return TRUE; } @@ -1061,34 +1054,22 @@ static void UploadGlyph(struct xrender_physdev *physDev, UINT glyph, enum glyph_ /* If there is nothing for the current type, we create the entry. */ if( !entry->format[type][format] ) { - entry->format[type][format] = HeapAlloc(GetProcessHeap(), - HEAP_ZERO_MEMORY, - sizeof(gsCacheEntryFormat)); + entry->format[type][format] = calloc( 1, sizeof(gsCacheEntryFormat) ); } formatEntry = entry->format[type][format]; if(formatEntry->nrealized <= glyph) { - formatEntry->nrealized = (glyph / 128 + 1) * 128; + size_t new_size = (glyph / 128 + 1) * 128; - if (formatEntry->realized) - formatEntry->realized = HeapReAlloc(GetProcessHeap(), - HEAP_ZERO_MEMORY, - formatEntry->realized, - formatEntry->nrealized * sizeof(BOOL)); - else - formatEntry->realized = HeapAlloc(GetProcessHeap(), - HEAP_ZERO_MEMORY, - formatEntry->nrealized * sizeof(BOOL)); + formatEntry->realized = realloc( formatEntry->realized, new_size * sizeof(BOOL) ); + memset( formatEntry->realized + formatEntry->nrealized, 0, + (new_size - formatEntry->nrealized) * sizeof(BOOL) ); - if (formatEntry->gis) - formatEntry->gis = HeapReAlloc(GetProcessHeap(), - HEAP_ZERO_MEMORY, - formatEntry->gis, - formatEntry->nrealized * sizeof(formatEntry->gis[0])); - else - formatEntry->gis = HeapAlloc(GetProcessHeap(), - HEAP_ZERO_MEMORY, - formatEntry->nrealized * sizeof(formatEntry->gis[0])); + formatEntry->gis = realloc( formatEntry->gis, new_size * sizeof(formatEntry->gis[0]) ); + memset( formatEntry->gis + formatEntry->nrealized, 0, + (new_size - formatEntry->nrealized) * sizeof(formatEntry->gis[0]) ); + + formatEntry->nrealized = new_size; } @@ -1118,7 +1099,7 @@ static void UploadGlyph(struct xrender_physdev *physDev, UINT glyph, enum glyph_ } - buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buflen); + buf = calloc( 1, buflen ); if (buflen) NtGdiGetGlyphOutline( physDev->dev.hdc, glyph, ggo_format, &gm, buflen, buf, &identity, FALSE ); else @@ -1209,7 +1190,7 @@ static void UploadGlyph(struct xrender_physdev *physDev, UINT glyph, enum glyph_ buflen ? buf : zero, buflen ? buflen : sizeof(zero)); } - HeapFree(GetProcessHeap(), 0, buf); + free( buf ); formatEntry->gis[glyph] = gi; } @@ -1369,7 +1350,7 @@ static BOOL CDECL xrenderdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, TRACE("Writing %s at %d,%d\n", debugstr_wn(wstr,count), physdev->x11dev->dc_rect.left + x, physdev->x11dev->dc_rect.top + y); - elts = HeapAlloc(GetProcessHeap(), 0, sizeof(XGlyphElt16) * count); + elts = malloc( sizeof(XGlyphElt16) * count ); /* There's a bug in XRenderCompositeText that ignores the xDst and yDst parameters. So we pass zeros to the function and move to our starting position using the first @@ -1431,7 +1412,7 @@ static BOOL CDECL xrenderdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, pict, formatEntry->font_format, 0, 0, 0, 0, elts, count); - HeapFree(GetProcessHeap(), 0, elts); + free( elts ); pthread_mutex_unlock( &xrender_mutex ); add_device_bounds( physdev->x11dev, &bounds ); @@ -1701,7 +1682,7 @@ static void xrender_put_image( Pixmap src_pixmap, Picture src_pict, Picture mask if (clip_data) pXRenderSetPictureClipRectangles( gdi_display, dst_pict, 0, 0, (XRectangle *)clip_data->Buffer, clip_data->rdh.nCount ); - HeapFree( GetProcessHeap(), 0, clip_data ); + free( clip_data ); } else { diff --git a/dlls/winex11.drv/xvidmode.c b/dlls/winex11.drv/xvidmode.c index d0be58342a5..126e2bf2a69 100644 --- a/dlls/winex11.drv/xvidmode.c +++ b/dlls/winex11.drv/xvidmode.c @@ -42,7 +42,6 @@ #include "windef.h" #include "wingdi.h" #include "wine/debug.h" -#include "wine/heap.h" WINE_DEFAULT_DEBUG_CHANNEL(xvidmode); @@ -134,7 +133,7 @@ static BOOL xf86vm_get_modes(ULONG_PTR id, DWORD flags, DEVMODEW **new_modes, UI /* Display modes in different color depth, with a XF86VidModeModeInfo * at the end of each * DEVMODEW as driver private data */ size += (xf86vm_mode_count * DEPTH_COUNT) * (sizeof(DEVMODEW) + sizeof(XF86VidModeModeInfo *)); - ptr = heap_alloc_zero(size); + ptr = calloc(1, size); if (!ptr) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); @@ -168,7 +167,7 @@ static void xf86vm_free_modes(DEVMODEW *modes) memcpy(&xf86vm_modes, (BYTE *)modes - sizeof(xf86vm_modes), sizeof(xf86vm_modes)); XFree(xf86vm_modes); } - heap_free(modes); + free(modes); } static BOOL xf86vm_get_current_mode(ULONG_PTR id, DEVMODEW *mode) @@ -454,7 +453,7 @@ static BOOL xf86vm_get_gamma_ramp(struct x11drv_gamma_ramp *ramp) } else { - if (!(red = heap_calloc(xf86vm_gammaramp_size, 3 * sizeof(*red)))) + if (!(red = calloc(xf86vm_gammaramp_size, 3 * sizeof(*red)))) return FALSE; green = red + xf86vm_gammaramp_size; blue = green + xf86vm_gammaramp_size; @@ -466,7 +465,7 @@ static BOOL xf86vm_get_gamma_ramp(struct x11drv_gamma_ramp *ramp) interpolate_gamma_ramp(ramp->red, ramp->green, ramp->blue, GAMMA_RAMP_SIZE, red, green, blue, xf86vm_gammaramp_size); if (red != ramp->red) - heap_free(red); + free(red); return ret; } @@ -483,7 +482,7 @@ static BOOL xf86vm_set_gamma_ramp(struct x11drv_gamma_ramp *ramp) } else { - if (!(red = heap_calloc(xf86vm_gammaramp_size, 3 * sizeof(*red)))) + if (!(red = calloc(xf86vm_gammaramp_size, 3 * sizeof(*red)))) return FALSE; green = red + xf86vm_gammaramp_size; blue = green + xf86vm_gammaramp_size; @@ -499,7 +498,7 @@ static BOOL xf86vm_set_gamma_ramp(struct x11drv_gamma_ramp *ramp) if (X11DRV_check_error()) ret = FALSE; if (red != ramp->red) - heap_free(red); + free(red); return ret; } #endif