[PATCH 4/5] winemac: Use libc for driver memory allocation.
Jacek Caban
wine at gitlab.winehq.org
Wed May 25 08:52:40 CDT 2022
From: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
---
dlls/winemac.drv/clipboard.c | 48 +++++++++++++++++-----------------
dlls/winemac.drv/display.c | 20 +++++++-------
dlls/winemac.drv/gdi.c | 4 +--
dlls/winemac.drv/keyboard.c | 2 +-
dlls/winemac.drv/macdrv_main.c | 4 +--
dlls/winemac.drv/mouse.c | 20 +++++++-------
dlls/winemac.drv/opengl.c | 29 ++++++++++----------
dlls/winemac.drv/surface.c | 15 +++++------
dlls/winemac.drv/vulkan.c | 9 +++----
dlls/winemac.drv/window.c | 28 +++++++++-----------
10 files changed, 88 insertions(+), 91 deletions(-)
diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c
index cdb4e5e02a8..d2780aa8bcb 100644
--- a/dlls/winemac.drv/clipboard.c
+++ b/dlls/winemac.drv/clipboard.c
@@ -253,7 +253,7 @@ static WINE_CLIPFORMAT *insert_clipboard_format(UINT id, CFStringRef type)
{
WINE_CLIPFORMAT *format;
- format = HeapAlloc(GetProcessHeap(), 0, sizeof(*format));
+ format = malloc(sizeof(*format));
if (format == NULL)
{
@@ -275,7 +275,7 @@ static WINE_CLIPFORMAT *insert_clipboard_format(UINT id, CFStringRef type)
if (!NtUserGetClipboardFormatName(format->format_id, buffer, ARRAY_SIZE(buffer)))
{
WARN("failed to get name for format %s; error 0x%08x\n", debugstr_format(format->format_id), GetLastError());
- HeapFree(GetProcessHeap(), 0, format);
+ free(format);
return NULL;
}
@@ -349,7 +349,7 @@ static void register_builtin_formats(void)
/* Register built-in formats */
for (i = 0; i < ARRAY_SIZE(builtin_format_ids); i++)
{
- if (!(format = HeapAlloc(GetProcessHeap(), 0, sizeof(*format)))) break;
+ if (!(format = malloc(sizeof(*format)))) break;
format->format_id = builtin_format_ids[i].id;
format->type = CFRetain(builtin_format_ids[i].type);
format->import_func = builtin_format_ids[i].import;
@@ -362,7 +362,7 @@ static void register_builtin_formats(void)
/* Register known mappings between Windows formats and Mac types */
for (i = 0; i < ARRAY_SIZE(builtin_format_names); i++)
{
- if (!(format = HeapAlloc(GetProcessHeap(), 0, sizeof(*format)))) break;
+ if (!(format = malloc(sizeof(*format)))) break;
format->format_id = register_clipboard_format(builtin_format_names[i].name);
format->import_func = builtin_format_names[i].import;
format->export_func = builtin_format_names[i].export;
@@ -416,7 +416,7 @@ static WINE_CLIPFORMAT* format_for_type(CFStringRef type)
LPWSTR name;
int len = CFStringGetLength(type) - CFStringGetLength(registered_name_type_prefix);
- name = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
+ name = malloc((len + 1) * sizeof(WCHAR));
CFStringGetCharacters(type, CFRangeMake(CFStringGetLength(registered_name_type_prefix), len),
(UniChar*)name);
name[len] = 0;
@@ -425,7 +425,7 @@ static WINE_CLIPFORMAT* format_for_type(CFStringRef type)
if (!format)
ERR("Failed to register format for type %s name %s\n", debugstr_cf(type), debugstr_w(name));
- HeapFree(GetProcessHeap(), 0, name);
+ free(name);
}
done:
@@ -707,14 +707,14 @@ static void *import_nsfilenames_to_hdrop(CFDataRef data, size_t *ret_size)
len = this_len;
}
- buffer = HeapAlloc(GetProcessHeap(), 0, len);
+ buffer = malloc(len);
if (!buffer)
{
WARN("failed to allocate buffer for file-system representations\n");
goto done;
}
- paths = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count * sizeof(paths[0]));
+ paths = calloc(count, sizeof(paths[0]));
if (!paths)
{
WARN("failed to allocate array of DOS paths\n");
@@ -766,9 +766,9 @@ done:
if (paths)
{
for (i = 0; i < count; i++) free(paths[i]);
- HeapFree(GetProcessHeap(), 0, paths);
+ free(paths);
}
- HeapFree(GetProcessHeap(), 0, buffer);
+ free(buffer);
if (names) CFRelease(names);
return dropfiles;
}
@@ -796,7 +796,7 @@ static void *import_utf8_to_unicodetext(CFDataRef data, size_t *ret_size)
new_lines++;
}
- if ((dst = HeapAlloc(GetProcessHeap(), 0, src_len + new_lines + 1)))
+ if ((dst = malloc(src_len + new_lines + 1)))
{
for (i = 0, j = 0; i < src_len; i++)
{
@@ -810,7 +810,7 @@ static void *import_utf8_to_unicodetext(CFDataRef data, size_t *ret_size)
if ((ret = malloc(j * sizeof(WCHAR))))
*ret_size = MultiByteToWideChar(CP_UTF8, 0, dst, j, ret, j) * sizeof(WCHAR);
- HeapFree(GetProcessHeap(), 0, dst);
+ free(dst);
}
return ret;
@@ -943,9 +943,9 @@ static CFDataRef export_hdrop_to_filenames(void *data, size_t size)
{
if (len > buffer_len)
{
- HeapFree(GetProcessHeap(), 0, buffer);
+ free(buffer);
buffer_len = len * 2;
- buffer = HeapAlloc(GetProcessHeap(), 0, buffer_len * sizeof(*buffer));
+ buffer = malloc(buffer_len * sizeof(*buffer));
}
MultiByteToWideChar(CP_ACP, 0, p, -1, buffer, buffer_len);
@@ -982,7 +982,7 @@ static CFDataRef export_hdrop_to_filenames(void *data, size_t size)
ret = CFPropertyListCreateData(NULL, filenames, kCFPropertyListXMLFormat_v1_0, 0, NULL);
done:
- HeapFree(GetProcessHeap(), 0, buffer);
+ free(buffer);
if (filenames) CFRelease(filenames);
TRACE(" -> %s\n", debugstr_cf(ret));
return ret;
@@ -1242,7 +1242,7 @@ static WINE_CLIPFORMAT** get_formats_for_pasteboard_types(CFArrayRef types, UINT
return NULL;
}
- formats = HeapAlloc(GetProcessHeap(), 0, count * sizeof(*formats));
+ formats = malloc(count * sizeof(*formats));
if (!formats)
{
WARN("Failed to allocate formats array\n");
@@ -1308,7 +1308,7 @@ static WINE_CLIPFORMAT** get_formats_for_pasteboard_types(CFArrayRef types, UINT
if (!pos)
{
- HeapFree(GetProcessHeap(), 0, formats);
+ free(formats);
formats = NULL;
}
@@ -1353,18 +1353,18 @@ UINT* macdrv_get_pasteboard_formats(CFTypeRef pasteboard, UINT* num_formats)
if (!formats)
return NULL;
- format_ids = HeapAlloc(GetProcessHeap(), 0, count);
+ format_ids = malloc(count);
if (!format_ids)
{
WARN("Failed to allocate formats IDs array\n");
- HeapFree(GetProcessHeap(), 0, formats);
+ free(formats);
return NULL;
}
for (i = 0; i < count; i++)
format_ids[i] = formats[i]->format_id;
- HeapFree(GetProcessHeap(), 0, formats);
+ free(formats);
*num_formats = count;
return format_ids;
@@ -1400,9 +1400,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);
@@ -1432,7 +1432,7 @@ static void set_mac_pasteboard_types_from_win32_clipboard(void)
}
}
- HeapFree(GetProcessHeap(), 0, formats);
+ free(formats);
return;
}
@@ -1455,7 +1455,7 @@ static void set_win32_clipboard_formats_from_mac_pasteboard(CFArrayRef types)
SetClipboardData(formats[i]->format_id, 0);
}
- HeapFree(GetProcessHeap(), 0, current_mac_formats);
+ free(current_mac_formats);
current_mac_formats = formats;
nb_current_mac_formats = count;
}
diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c
index dc22131e36a..5dbfe9338ce 100644
--- a/dlls/winemac.drv/display.c
+++ b/dlls/winemac.drv/display.c
@@ -264,7 +264,7 @@ static BOOL write_display_settings(HKEY parent_hkey, CGDirectDisplayID displayID
pixel_encoding = CGDisplayModeCopyPixelEncoding(display_mode);
len = CFStringGetLength(pixel_encoding);
- buf = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
+ buf = malloc((len + 1) * sizeof(WCHAR));
CFStringGetCharacters(pixel_encoding, CFRangeMake(0, len), (UniChar*)buf);
buf[len] = 0;
CFRelease(pixel_encoding);
@@ -275,7 +275,7 @@ static BOOL write_display_settings(HKEY parent_hkey, CGDirectDisplayID displayID
ret = TRUE;
fail:
- HeapFree(GetProcessHeap(), 0, buf);
+ free(buf);
if (display_mode) CGDisplayModeRelease(display_mode);
NtClose(display_hkey);
if (!ret)
@@ -359,7 +359,7 @@ static void free_display_mode_descriptor(struct display_mode_descriptor* desc)
{
if (desc->pixel_encoding)
CFRelease(desc->pixel_encoding);
- HeapFree(GetProcessHeap(), 0, desc);
+ free(desc);
}
}
@@ -384,7 +384,7 @@ static struct display_mode_descriptor* create_original_display_mode_descriptor(C
if (!(hkey = reg_open_key(NULL, nameW, asciiz_to_unicode(nameW, display_key))))
return NULL;
- desc = HeapAlloc(GetProcessHeap(), 0, sizeof(*desc));
+ desc = malloc(sizeof(*desc));
desc->pixel_encoding = NULL;
if (!read_dword(hkey, "Width", &desc->width) ||
@@ -761,10 +761,10 @@ static CFArrayRef copy_display_modes(CGDirectDisplayID display, BOOL include_uns
CFRelease(modes);
count = CFDictionaryGetCount(modes_by_size);
- mode_array = HeapAlloc(GetProcessHeap(), 0, count * sizeof(mode_array[0]));
+ mode_array = malloc(count * sizeof(mode_array[0]));
CFDictionaryGetKeysAndValues(modes_by_size, NULL, (const void **)mode_array);
modes = CFArrayCreate(NULL, (const void **)mode_array, count, &kCFTypeArrayCallBacks);
- HeapFree(GetProcessHeap(), 0, mode_array);
+ free(mode_array);
CFRelease(modes_by_size);
}
else
@@ -1261,7 +1261,7 @@ BOOL macdrv_GetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp)
}
mac_entries = CGDisplayGammaTableCapacity(displays[0].displayID);
- red = HeapAlloc(GetProcessHeap(), 0, mac_entries * sizeof(red[0]) * 3);
+ red = malloc(mac_entries * sizeof(red[0]) * 3);
if (!red)
goto done;
green = red + mac_entries;
@@ -1316,7 +1316,7 @@ BOOL macdrv_GetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp)
ret = TRUE;
done:
- HeapFree(GetProcessHeap(), 0, red);
+ free(red);
macdrv_free_displays(displays);
return ret;
}
@@ -1348,7 +1348,7 @@ BOOL macdrv_SetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp)
return FALSE;
}
- red = HeapAlloc(GetProcessHeap(), 0, win_entries * sizeof(red[0]) * 3);
+ red = malloc(win_entries * sizeof(red[0]) * 3);
if (!red)
goto done;
green = red + win_entries;
@@ -1366,7 +1366,7 @@ BOOL macdrv_SetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp)
WARN("failed to set display gamma table: %d\n", err);
done:
- HeapFree(GetProcessHeap(), 0, red);
+ free(red);
macdrv_free_displays(displays);
return (err == kCGErrorSuccess);
}
diff --git a/dlls/winemac.drv/gdi.c b/dlls/winemac.drv/gdi.c
index 151bb144da1..8d41778b472 100644
--- a/dlls/winemac.drv/gdi.c
+++ b/dlls/winemac.drv/gdi.c
@@ -157,7 +157,7 @@ static MACDRV_PDEVICE *create_mac_physdev(void)
if (!device_data_valid) device_init();
pthread_mutex_unlock(&device_data_mutex);
- if (!(physDev = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*physDev)))) return NULL;
+ if (!(physDev = calloc(1, sizeof(*physDev)))) return NULL;
return physDev;
}
@@ -207,7 +207,7 @@ static BOOL CDECL macdrv_DeleteDC(PHYSDEV dev)
TRACE("hdc %p\n", dev->hdc);
- HeapFree(GetProcessHeap(), 0, physDev);
+ free(physDev);
return TRUE;
}
diff --git a/dlls/winemac.drv/keyboard.c b/dlls/winemac.drv/keyboard.c
index 9dca17e5c4e..d3e9dca9055 100644
--- a/dlls/winemac.drv/keyboard.c
+++ b/dlls/winemac.drv/keyboard.c
@@ -530,7 +530,7 @@ static void update_layout_list(void)
CFStringRef type = CFDictionaryGetValue(dict, macdrv_input_source_type_key);
CFStringRef lang = CFDictionaryGetValue(dict, macdrv_input_source_lang_key);
- layout = HeapAlloc(GetProcessHeap(), 0, sizeof(*layout));
+ layout = malloc(sizeof(*layout));
layout->input_source = (TISInputSourceRef)CFRetain(input);
layout->hkl = get_hkl(lang, type);
diff --git a/dlls/winemac.drv/macdrv_main.c b/dlls/winemac.drv/macdrv_main.c
index 8c101576e99..fbd4663373b 100644
--- a/dlls/winemac.drv/macdrv_main.c
+++ b/dlls/winemac.drv/macdrv_main.c
@@ -487,7 +487,7 @@ void macdrv_ThreadDetach(void)
macdrv_destroy_event_queue(data->queue);
if (data->keyboard_layout_uchr)
CFRelease(data->keyboard_layout_uchr);
- 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 = 0;
}
@@ -534,7 +534,7 @@ struct macdrv_thread_data *macdrv_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);
diff --git a/dlls/winemac.drv/mouse.c b/dlls/winemac.drv/mouse.c
index 52e978567de..4d672029833 100644
--- a/dlls/winemac.drv/mouse.c
+++ b/dlls/winemac.drv/mouse.c
@@ -282,7 +282,7 @@ CFArrayRef create_monochrome_cursor(HDC hdc, const ICONINFOEXW *icon, int width,
info->bmiHeader.biClrUsed = 0;
info->bmiHeader.biClrImportant = 0;
- and_bits = HeapAlloc(GetProcessHeap(), 0, info->bmiHeader.biSizeImage);
+ and_bits = malloc(info->bmiHeader.biSizeImage);
if (!and_bits)
{
WARN("failed to allocate and_bits\n");
@@ -293,7 +293,7 @@ CFArrayRef create_monochrome_cursor(HDC hdc, const ICONINFOEXW *icon, int width,
if (!NtGdiGetDIBitsInternal(hdc, icon->hbmMask, 0, height * 2, and_bits, info, DIB_RGB_COLORS, 0, 0))
{
WARN("GetDIBits failed\n");
- HeapFree(GetProcessHeap(), 0, and_bits);
+ free(and_bits);
return NULL;
}
@@ -332,7 +332,7 @@ CFArrayRef create_monochrome_cursor(HDC hdc, const ICONINFOEXW *icon, int width,
if (!data)
{
WARN("failed to create data\n");
- HeapFree(GetProcessHeap(), 0, and_bits);
+ free(and_bits);
return NULL;
}
@@ -349,7 +349,7 @@ CFArrayRef create_monochrome_cursor(HDC hdc, const ICONINFOEXW *icon, int width,
{
WARN("failed to create colorspace\n");
CFRelease(data);
- HeapFree(GetProcessHeap(), 0, and_bits);
+ free(and_bits);
return NULL;
}
@@ -359,7 +359,7 @@ CFArrayRef create_monochrome_cursor(HDC hdc, const ICONINFOEXW *icon, int width,
{
WARN("failed to create data provider\n");
CGColorSpaceRelease(colorspace);
- HeapFree(GetProcessHeap(), 0, and_bits);
+ free(and_bits);
return NULL;
}
@@ -371,7 +371,7 @@ CFArrayRef create_monochrome_cursor(HDC hdc, const ICONINFOEXW *icon, int width,
if (!cgimage)
{
WARN("failed to create image\n");
- HeapFree(GetProcessHeap(), 0, and_bits);
+ free(and_bits);
return NULL;
}
@@ -381,7 +381,7 @@ CFArrayRef create_monochrome_cursor(HDC hdc, const ICONINFOEXW *icon, int width,
{
WARN("failed to create data\n");
CGImageRelease(cgimage);
- HeapFree(GetProcessHeap(), 0, and_bits);
+ free(and_bits);
return NULL;
}
@@ -391,7 +391,7 @@ CFArrayRef create_monochrome_cursor(HDC hdc, const ICONINFOEXW *icon, int width,
data_bits = (unsigned long*)CFDataGetMutableBytePtr(data);
for (i = 0; i < count; i++)
data_bits[i] &= ~xor_bits[i];
- HeapFree(GetProcessHeap(), 0, and_bits);
+ free(and_bits);
provider = CGDataProviderCreateWithCFData(data);
CFRelease(data);
@@ -566,7 +566,7 @@ static CFArrayRef create_color_cursor(HDC hdc, const ICONINFOEXW *iinfo, HANDLE
}
/* 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;
@@ -629,7 +629,7 @@ cleanup:
/* Cleanup all of the resources used to obtain the frame data */
if (hbmColor) NtGdiDeleteObjectApp(hbmColor);
if (hbmMask) NtGdiDeleteObjectApp(hbmMask);
- HeapFree(GetProcessHeap(), 0, info);
+ free(info);
return frames;
}
diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c
index 3aa5c340e30..9f884e33c18 100644
--- a/dlls/winemac.drv/opengl.c
+++ b/dlls/winemac.drv/opengl.c
@@ -1164,7 +1164,7 @@ static BOOL init_pixel_formats(void)
range = CFRangeMake(0, CFArrayGetCount(pixel_format_array));
if (range.length)
{
- pixel_formats = HeapAlloc(GetProcessHeap(), 0, range.length * sizeof(*pixel_formats));
+ pixel_formats = malloc(range.length * sizeof(*pixel_formats));
if (pixel_formats)
{
CFArraySortValues(pixel_format_array, range, pixel_format_comparator, NULL);
@@ -1273,7 +1273,7 @@ static BOOL init_gl_info(void)
length = strlen(str) + sizeof(legacy_extensions);
if (allow_vsync)
length += strlen(legacy_ext_swap_control);
- gl_info.glExtensions = HeapAlloc(GetProcessHeap(), 0, length);
+ gl_info.glExtensions = malloc(length);
strcpy(gl_info.glExtensions, str);
strcat(gl_info.glExtensions, legacy_extensions);
if (allow_vsync)
@@ -1924,7 +1924,7 @@ static void get_fallback_renderer_version(GLuint *value)
if (version && CFGetTypeID(version) == CFStringGetTypeID())
{
size_t len = CFStringGetMaximumSizeForEncoding(CFStringGetLength(version), kCFStringEncodingUTF8);
- char* buf = HeapAlloc(GetProcessHeap(), 0, len);
+ char* buf = malloc(len);
if (buf && CFStringGetCString(version, buf, len, kCFStringEncodingUTF8))
{
unsigned int major, minor, bugfix;
@@ -1940,7 +1940,7 @@ static void get_fallback_renderer_version(GLuint *value)
got_it = TRUE;
}
}
- HeapFree(GetProcessHeap(), 0, buf);
+ free(buf);
}
CFRelease(bundle);
}
@@ -2859,13 +2859,13 @@ static struct wgl_context *macdrv_wglCreateContextAttribsARB(HDC hdc,
return NULL;
}
- if (!(context = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*context)))) return NULL;
+ if (!(context = calloc(1, sizeof(*context)))) return NULL;
context->format = format;
context->renderer_id = renderer_id;
if (!create_context(context, share_context ? share_context->cglcontext : NULL, major))
{
- HeapFree(GetProcessHeap(), 0, context);
+ free(context);
return NULL;
}
@@ -2900,7 +2900,7 @@ static struct wgl_pbuffer *macdrv_wglCreatePbufferARB(HDC hdc, int iPixelFormat,
return NULL;
}
- pbuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pbuffer));
+ pbuffer = calloc(1, sizeof(*pbuffer));
pbuffer->format = iPixelFormat;
for ( ; piAttribList && *piAttribList; piAttribList += 2)
@@ -3011,7 +3011,7 @@ static struct wgl_pbuffer *macdrv_wglCreatePbufferARB(HDC hdc, int iPixelFormat,
done:
if (!pbuffer->pbuffer)
{
- HeapFree(GetProcessHeap(), 0, pbuffer);
+ free(pbuffer);
return NULL;
}
@@ -3030,7 +3030,7 @@ static BOOL macdrv_wglDestroyPbufferARB(struct wgl_pbuffer *pbuffer)
TRACE("pbuffer %p\n", pbuffer);
if (pbuffer && pbuffer->pbuffer)
CGLReleasePBuffer(pbuffer->pbuffer);
- HeapFree(GetProcessHeap(), 0, pbuffer);
+ free(pbuffer);
return GL_TRUE;
}
@@ -3079,7 +3079,7 @@ static HDC macdrv_wglGetPbufferDCARB(struct wgl_pbuffer *pbuffer)
if (prev)
{
CGLReleasePBuffer(prev->pbuffer);
- HeapFree(GetProcessHeap(), 0, prev);
+ free(prev);
}
CFDictionarySetValue(dc_pbuffers, hdc, pbuffer);
pthread_mutex_unlock(&dc_pbuffers_mutex);
@@ -3399,7 +3399,7 @@ static BOOL macdrv_wglGetPixelFormatAttribfvARB(HDC hdc, int iPixelFormat, int i
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);
@@ -3418,7 +3418,7 @@ static BOOL macdrv_wglGetPixelFormatAttribfvARB(HDC hdc, int iPixelFormat, int i
pfValues[i] = attr[i];
}
- HeapFree(GetProcessHeap(), 0, attr);
+ free(attr);
return ret;
}
@@ -3925,7 +3925,7 @@ static int macdrv_wglReleasePbufferDCARB(struct wgl_pbuffer *pbuffer, HDC hdc)
if (prev != pbuffer)
FIXME("hdc %p isn't associated with pbuffer %p\n", hdc, pbuffer);
CGLReleasePBuffer(prev->pbuffer);
- HeapFree(GetProcessHeap(), 0, prev);
+ free(prev);
CFDictionaryRemoveValue(dc_pbuffers, hdc);
}
else hdc = 0;
@@ -4403,7 +4403,8 @@ static BOOL WINAPI macdrv_wglDeleteContext(struct wgl_context *context)
pthread_mutex_unlock(&context_mutex);
macdrv_dispose_opengl_context(context->context);
- return HeapFree(GetProcessHeap(), 0, context);
+ free(context);
+ return TRUE;
}
/***********************************************************************
diff --git a/dlls/winemac.drv/surface.c b/dlls/winemac.drv/surface.c
index 9605e704c92..5d51d18422a 100644
--- a/dlls/winemac.drv/surface.c
+++ b/dlls/winemac.drv/surface.c
@@ -77,7 +77,7 @@ static struct macdrv_window_surface *get_mac_surface(struct window_surface *surf
*/
static void update_blit_data(struct macdrv_window_surface *surface)
{
- HeapFree(GetProcessHeap(), 0, surface->blit_data);
+ free(surface->blit_data);
surface->blit_data = NULL;
if (surface->drawn)
@@ -209,10 +209,10 @@ static void macdrv_surface_destroy(struct window_surface *window_surface)
TRACE("freeing %p bits %p\n", surface, surface->bits);
if (surface->region) NtGdiDeleteObjectApp(surface->region);
if (surface->drawn) NtGdiDeleteObjectApp(surface->drawn);
- HeapFree(GetProcessHeap(), 0, surface->blit_data);
- HeapFree(GetProcessHeap(), 0, surface->bits);
+ free(surface->blit_data);
+ free(surface->bits);
pthread_mutex_destroy(&surface->mutex);
- HeapFree(GetProcessHeap(), 0, surface);
+ free(surface);
}
static const struct window_surface_funcs macdrv_surface_funcs =
@@ -246,8 +246,7 @@ struct window_surface *create_surface(macdrv_window window, const RECT *rect,
int err;
DWORD window_background;
- surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
- FIELD_OFFSET(struct macdrv_window_surface, info.bmiColors[3]));
+ surface = calloc(1, FIELD_OFFSET(struct macdrv_window_surface, info.bmiColors[3]));
if (!surface) return NULL;
err = pthread_mutexattr_init(&attr);
@@ -260,7 +259,7 @@ struct window_surface *create_surface(macdrv_window window, const RECT *rect,
}
if (err)
{
- HeapFree(GetProcessHeap(), 0, surface);
+ free(surface);
return NULL;
}
@@ -295,7 +294,7 @@ struct window_surface *create_surface(macdrv_window window, const RECT *rect,
}
update_blit_data(surface);
surface->use_alpha = use_alpha;
- surface->bits = HeapAlloc(GetProcessHeap(), 0, surface->info.bmiHeader.biSizeImage);
+ surface->bits = malloc(surface->info.bmiHeader.biSizeImage);
if (!surface->bits) goto failed;
window_background = macdrv_window_background_color();
memset_pattern4(surface->bits, &window_background, surface->info.bmiHeader.biSizeImage);
diff --git a/dlls/winemac.drv/vulkan.c b/dlls/winemac.drv/vulkan.c
index de99e4035bc..8481176fd70 100644
--- a/dlls/winemac.drv/vulkan.c
+++ b/dlls/winemac.drv/vulkan.c
@@ -29,7 +29,6 @@
#include "macdrv.h"
#include "wine/debug.h"
-#include "wine/heap.h"
#define VK_NO_PROTOTYPES
#define WINE_VK_HOST
@@ -157,7 +156,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");
@@ -199,7 +198,7 @@ static void wine_vk_surface_destroy(VkInstance instance, struct wine_vk_surface
if (surface->device)
macdrv_release_metal_device(surface->device);
- heap_free(surface);
+ free(surface);
}
static VkResult macdrv_vkCreateInstance(const VkInstanceCreateInfo *create_info,
@@ -225,7 +224,7 @@ static VkResult macdrv_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;
}
@@ -265,7 +264,7 @@ static VkResult macdrv_vkCreateWin32SurfaceKHR(VkInstance instance,
return VK_ERROR_INCOMPATIBLE_DRIVER;
}
- mac_surface = heap_alloc_zero(sizeof(*mac_surface));
+ mac_surface = calloc(1, sizeof(*mac_surface));
if (!mac_surface)
{
release_win_data(data);
diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c
index 9faad78ac5e..4d55a277833 100644
--- a/dlls/winemac.drv/window.c
+++ b/dlls/winemac.drv/window.c
@@ -238,7 +238,7 @@ static struct macdrv_win_data *alloc_win_data(HWND hwnd)
{
struct macdrv_win_data *data;
- if ((data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data))))
+ if ((data = calloc(1, sizeof(*data))))
{
data->hwnd = hwnd;
data->color_key = CLR_INVALID;
@@ -425,7 +425,7 @@ static void sync_window_region(struct macdrv_win_data *data, HRGN win_region)
TRACE("win %p/%p win_region %p rects %p count %d\n", data->hwnd, data->cocoa_window, win_region, rects, count);
macdrv_set_window_shape(data->cocoa_window, rects, count);
- HeapFree(GetProcessHeap(), 0, region_data);
+ free(region_data);
data->shaped = (region_data != NULL);
if (hrgn && hrgn != win_region) NtGdiDeleteObjectApp(hrgn);
@@ -1043,8 +1043,7 @@ static void sync_window_z_order(struct macdrv_win_data *data)
* get_region_data
*
* Calls GetRegionData on the given region and converts the rectangle
- * array to CGRect format. The returned buffer must be freed by
- * caller using HeapFree(GetProcessHeap(),...).
+ * array to CGRect format. The returned buffer must be freed by caller.
* If hdc_lptodp is not 0, the rectangles are converted through LPtoDP.
*/
RGNDATA *get_region_data(HRGN hrgn, HDC hdc_lptodp)
@@ -1062,10 +1061,10 @@ RGNDATA *get_region_data(HRGN hrgn, HDC hdc_lptodp)
int count = (size - sizeof(RGNDATAHEADER)) / sizeof(RECT);
size += count * (sizeof(CGRect) - 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;
}
@@ -1626,7 +1625,7 @@ void macdrv_DestroyWindow(HWND hwnd)
CFDictionaryRemoveValue(win_datas, hwnd);
release_win_data(data);
- HeapFree(GetProcessHeap(), 0, data);
+ free(data);
}
@@ -2686,8 +2685,7 @@ static BOOL CALLBACK get_process_windows(HWND hwnd, LPARAM lp)
if (qi->count >= qi->capacity)
{
UINT new_cap = qi->capacity * 2;
- HWND *new_wins = HeapReAlloc(GetProcessHeap(), 0, qi->wins,
- new_cap * sizeof(*qi->wins));
+ HWND *new_wins = realloc(qi->wins, new_cap * sizeof(*qi->wins));
if (!new_wins) return FALSE;
qi->wins = new_wins;
qi->capacity = new_cap;
@@ -2766,8 +2764,8 @@ static void CALLBACK quit_callback(HWND hwnd, UINT msg, ULONG_PTR data, LRESULT
if (qi->result)
TerminateProcess(GetCurrentProcess(), 0);
- HeapFree(GetProcessHeap(), 0, qi->wins);
- HeapFree(GetProcessHeap(), 0, qi);
+ free(qi->wins);
+ free(qi);
}
}
}
@@ -2785,12 +2783,12 @@ void macdrv_app_quit_requested(const macdrv_event *event)
TRACE("reason %d\n", event->app_quit_requested.reason);
- qi = HeapAlloc(GetProcessHeap(), 0, sizeof(*qi));
+ qi = malloc(sizeof(*qi));
if (!qi)
goto fail;
qi->capacity = 32;
- qi->wins = HeapAlloc(GetProcessHeap(), 0, qi->capacity * sizeof(*qi->wins));
+ qi->wins = malloc(qi->capacity * sizeof(*qi->wins));
qi->count = qi->done = 0;
if (!qi->wins || !EnumWindows(get_process_windows, (LPARAM)qi))
@@ -2836,8 +2834,8 @@ fail:
WARN("failed to allocate window list\n");
if (qi)
{
- HeapFree(GetProcessHeap(), 0, qi->wins);
- HeapFree(GetProcessHeap(), 0, qi);
+ free(qi->wins);
+ free(qi);
}
macdrv_quit_reply(FALSE);
}
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/129
More information about the wine-devel
mailing list