From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/clipboard.c | 152 +++++++++++------------------------ 1 file changed, 47 insertions(+), 105 deletions(-)
diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c index af3870b4cc6..b11b56a9ac4 100644 --- a/dlls/winemac.drv/clipboard.c +++ b/dlls/winemac.drv/clipboard.c @@ -41,7 +41,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(clipboard); **************************************************************************/
typedef void *(*DRVIMPORTFUNC)(CFDataRef data, size_t *ret_size); -typedef CFDataRef (*DRVEXPORTFUNC)(HANDLE data); +typedef CFDataRef (*DRVEXPORTFUNC)(void *data, size_t size);
typedef struct _WINE_CLIPFORMAT { @@ -73,13 +73,12 @@ static void *import_nsfilenames_to_hdrop(CFDataRef data, size_t *ret_size); static void *import_utf8_to_unicodetext(CFDataRef data, size_t *ret_size); static void *import_utf16_to_unicodetext(CFDataRef data, size_t *ret_size);
-static CFDataRef export_clipboard_data(HANDLE data); -static CFDataRef export_dib_to_bmp(HANDLE data); -static CFDataRef export_enhmetafile(HANDLE data); -static CFDataRef export_hdrop_to_filenames(HANDLE data); -static CFDataRef export_html(HANDLE data); -static CFDataRef export_unicodetext_to_utf8(HANDLE data); -static CFDataRef export_unicodetext_to_utf16(HANDLE data); +static CFDataRef export_clipboard_data(void *data, size_t size); +static CFDataRef export_dib_to_bmp(void *data, size_t size); +static CFDataRef export_hdrop_to_filenames(void *data, size_t size); +static CFDataRef export_html(void *data, size_t size); +static CFDataRef export_unicodetext_to_utf8(void *data, size_t size); +static CFDataRef export_unicodetext_to_utf16(void *data, size_t size);
/************************************************************************** @@ -137,7 +136,7 @@ static const struct { { CF_DIBV5, CFSTR("org.winehq.builtin.dibv5"), import_clipboard_data, export_clipboard_data, FALSE }, { CF_DIF, CFSTR("org.winehq.builtin.dif"), import_clipboard_data, export_clipboard_data, FALSE }, - { CF_ENHMETAFILE, CFSTR("org.winehq.builtin.enhmetafile"), import_clipboard_data, export_enhmetafile, FALSE }, + { CF_ENHMETAFILE, CFSTR("org.winehq.builtin.enhmetafile"), import_clipboard_data, export_clipboard_data, FALSE }, { CF_LOCALE, CFSTR("org.winehq.builtin.locale"), import_clipboard_data, export_clipboard_data, FALSE }, { CF_OEMTEXT, CFSTR("org.winehq.builtin.oemtext"), import_clipboard_data, export_clipboard_data, FALSE }, { CF_PALETTE, CFSTR("org.winehq.builtin.palette"), import_clipboard_data, export_clipboard_data, FALSE }, @@ -770,20 +769,9 @@ static void *import_utf16_to_unicodetext(CFDataRef data, size_t *ret_size) * * Generic export clipboard data routine. */ -static CFDataRef export_clipboard_data(HANDLE data) +static CFDataRef export_clipboard_data(void *data, size_t size) { - CFDataRef ret; - UINT len; - LPVOID src; - - len = GlobalSize(data); - src = GlobalLock(data); - if (!src) return NULL; - - ret = CFDataCreate(NULL, src, len); - GlobalUnlock(data); - - return ret; + return CFDataCreate(NULL, data, size); }
@@ -793,18 +781,13 @@ static CFDataRef export_clipboard_data(HANDLE data) * Export CF_DIB or CF_DIBV5 to BMP file format. This just entails * prepending a BMP file format header to the data. */ -static CFDataRef export_dib_to_bmp(HANDLE data) +static CFDataRef export_dib_to_bmp(void *data, size_t size) { CFMutableDataRef ret = NULL; - BYTE *dibdata; CFIndex len; BITMAPFILEHEADER bfh;
- dibdata = GlobalLock(data); - if (!dibdata) - return NULL; - - len = sizeof(bfh) + GlobalSize(data); + len = sizeof(bfh) + size; ret = CFDataCreateMutable(NULL, len); if (ret) { @@ -812,39 +795,13 @@ static CFDataRef export_dib_to_bmp(HANDLE data) bfh.bfSize = len; bfh.bfReserved1 = 0; bfh.bfReserved2 = 0; - bfh.bfOffBits = sizeof(bfh) + bitmap_info_size((BITMAPINFO*)dibdata, DIB_RGB_COLORS); + bfh.bfOffBits = sizeof(bfh) + bitmap_info_size(data, DIB_RGB_COLORS); CFDataAppendBytes(ret, (UInt8*)&bfh, sizeof(bfh));
/* rest of bitmap is the same as the packed dib */ - CFDataAppendBytes(ret, (UInt8*)dibdata, len - sizeof(bfh)); - } - - GlobalUnlock(data); - - return ret; -} - - -/************************************************************************** - * export_enhmetafile - * - * Export an enhanced metafile to data. - */ -static CFDataRef export_enhmetafile(HANDLE data) -{ - CFMutableDataRef ret = NULL; - unsigned int size = GetEnhMetaFileBits(data, 0, NULL); - - TRACE("data %p\n", data); - - ret = CFDataCreateMutable(NULL, size); - if (ret) - { - CFDataSetLength(ret, size); - GetEnhMetaFileBits(data, size, (BYTE*)CFDataGetMutableBytePtr(ret)); + CFDataAppendBytes(ret, data, size); }
- TRACE(" -> %s\n", debugstr_cf(ret)); return ret; }
@@ -855,10 +812,10 @@ static CFDataRef export_enhmetafile(HANDLE data) * Export CF_HDROP to NSFilenamesPboardType data, which is a CFArray of * CFStrings (holding Unix paths) which is serialized as a property list. */ -static CFDataRef export_hdrop_to_filenames(HANDLE data) +static CFDataRef export_hdrop_to_filenames(void *data, size_t size) { CFDataRef ret = NULL; - DROPFILES *dropfiles; + DROPFILES *dropfiles = data; CFMutableArrayRef filenames = NULL; void *p; WCHAR *buffer = NULL; @@ -866,12 +823,6 @@ static CFDataRef export_hdrop_to_filenames(HANDLE data)
TRACE("data %p\n", data);
- if (!(dropfiles = GlobalLock(data))) - { - WARN("failed to lock data %p\n", data); - goto done; - } - filenames = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); if (!filenames) { @@ -935,7 +886,6 @@ static CFDataRef export_hdrop_to_filenames(HANDLE data)
done: HeapFree(GetProcessHeap(), 0, buffer); - GlobalUnlock(data); if (filenames) CFRelease(filenames); TRACE(" -> %s\n", debugstr_cf(ret)); return ret; @@ -949,20 +899,17 @@ done: * * FIXME: We should attempt to add an <a base> tag and convert windows paths. */ -static CFDataRef export_html(HANDLE handle) +static CFDataRef export_html(void *data, size_t size) { - CFDataRef ret; - const char *data, *field_value; + const char *field_value; int fragmentstart, fragmentend;
- data = GlobalLock(handle); - /* read the important fields */ field_value = get_html_description_field(data, "StartFragment:"); if (!field_value) { ERR("Couldn't find StartFragment value\n"); - goto failed; + return NULL; } fragmentstart = atoi(field_value);
@@ -970,18 +917,12 @@ static CFDataRef export_html(HANDLE handle) if (!field_value) { ERR("Couldn't find EndFragment value\n"); - goto failed; + return NULL; } fragmentend = atoi(field_value);
/* export only the fragment */ - ret = CFDataCreate(NULL, (const UInt8*)&data[fragmentstart], fragmentend - fragmentstart); - GlobalUnlock(handle); - return ret; - -failed: - GlobalUnlock(handle); - return NULL; + return CFDataCreate(NULL, &((const UInt8*)data)[fragmentstart], fragmentend - fragmentstart); }
@@ -990,16 +931,12 @@ failed: * * Export CF_UNICODETEXT to UTF-8. */ -static CFDataRef export_unicodetext_to_utf8(HANDLE data) +static CFDataRef export_unicodetext_to_utf8(void *data, size_t size) { CFMutableDataRef ret; - LPVOID src; INT dst_len;
- src = GlobalLock(data); - if (!src) return NULL; - - dst_len = WideCharToMultiByte(CP_UTF8, 0, src, -1, NULL, 0, NULL, NULL); + dst_len = WideCharToMultiByte(CP_UTF8, 0, data, -1, NULL, 0, NULL, NULL); if (dst_len) dst_len--; /* Leave off null terminator. */ ret = CFDataCreateMutable(NULL, dst_len); if (ret) @@ -1009,7 +946,7 @@ static CFDataRef export_unicodetext_to_utf8(HANDLE data)
CFDataSetLength(ret, dst_len); dst = (LPSTR)CFDataGetMutableBytePtr(ret); - WideCharToMultiByte(CP_UTF8, 0, src, -1, dst, dst_len, NULL, NULL); + WideCharToMultiByte(CP_UTF8, 0, data, -1, dst, dst_len, NULL, NULL);
/* Remove carriage returns */ for (i = 0, j = 0; i < dst_len; i++) @@ -1021,7 +958,6 @@ static CFDataRef export_unicodetext_to_utf8(HANDLE data) } CFDataSetLength(ret, j); } - GlobalUnlock(data);
return ret; } @@ -1032,16 +968,13 @@ static CFDataRef export_unicodetext_to_utf8(HANDLE data) * * Export CF_UNICODETEXT to UTF-16. */ -static CFDataRef export_unicodetext_to_utf16(HANDLE data) +static CFDataRef export_unicodetext_to_utf16(void *data, size_t size) { CFMutableDataRef ret; - const WCHAR *src; + const WCHAR *src = data; INT src_len;
- src = GlobalLock(data); - if (!src) return NULL; - - src_len = GlobalSize(data) / sizeof(WCHAR); + src_len = size / sizeof(WCHAR); if (src_len) src_len--; /* Leave off null terminator. */ ret = CFDataCreateMutable(NULL, src_len * sizeof(WCHAR)); if (ret) @@ -1062,7 +995,6 @@ static CFDataRef export_unicodetext_to_utf16(HANDLE data) } CFDataSetLength(ret, j * sizeof(WCHAR)); } - GlobalUnlock(data);
return ret; } @@ -1912,35 +1844,45 @@ done: */ BOOL query_pasteboard_data(HWND hwnd, CFStringRef type) { + struct get_clipboard_params params = { .data_only = TRUE, .size = 1024 }; WINE_CLIPFORMAT *format; BOOL ret = FALSE; - HANDLE handle;
TRACE("win %p/%p type %s\n", hwnd, clipboard_cocoa_window, debugstr_cf(type));
format = format_for_type(type); if (!format) return FALSE;
- if (!OpenClipboard(clipboard_hwnd)) + if (!NtUserOpenClipboard(clipboard_hwnd, 0)) { ERR("failed to open clipboard for %s\n", debugstr_cf(type)); return FALSE; }
- if ((handle = GetClipboardData(format->format_id))) + for (;;) { - CFDataRef data; + if (!(params.data = malloc(params.size))) break; + if (NtUserGetClipboardData(format->format_id, ¶ms)) + { + CFDataRef data;
- TRACE("exporting %s %p\n", debugstr_format(format->format_id), handle); + TRACE("exporting %s\n", debugstr_format(format->format_id));
- if ((data = format->export_func(handle))) - { - ret = macdrv_set_pasteboard_data(format->type, data, clipboard_cocoa_window); - CFRelease(data); + if ((data = format->export_func(params.data, params.size))) + { + ret = macdrv_set_pasteboard_data(format->type, data, clipboard_cocoa_window); + CFRelease(data); + } + free(params.data); + break; } + free(params.data); + if (!params.data_size) break; + params.size = params.data_size; + params.data_size = 0; }
- last_get_seqno = GetClipboardSequenceNumber(); + last_get_seqno = NtUserGetClipboardSequenceNumber();
NtUserCloseClipboard();
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/clipboard.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c index b11b56a9ac4..93706680470 100644 --- a/dlls/winemac.drv/clipboard.c +++ b/dlls/winemac.drv/clipboard.c @@ -565,6 +565,29 @@ static void *import_html(CFDataRef data, size_t *ret_size) }
+/* based on wine_get_dos_file_name */ +static WCHAR *get_dos_file_name(const char *path) +{ + ULONG len = strlen(path) + 9; /* ??\unix prefix */ + WCHAR *ret; + + if (!(ret = malloc(len * sizeof(WCHAR)))) return NULL; + if (wine_unix_to_nt_file_name(path, ret, &len)) + { + free(ret); + return NULL; + } + + if (ret[5] == ':') + { + /* get rid of the ??\ prefix */ + memmove(ret, ret + 4, (len - 4) * sizeof(WCHAR)); + } + else ret[1] = '\'; + return ret; +} + + /************************************************************************** * import_nsfilenames_to_hdrop * @@ -632,7 +655,7 @@ static void *import_nsfilenames_to_hdrop(CFDataRef data, size_t *ret_size) WARN("failed to get file-system representation for %s\n", debugstr_cf(name)); goto done; } - paths[i] = wine_get_dos_file_name(buffer); + paths[i] = get_dos_file_name(buffer); if (!paths[i]) { WARN("failed to get DOS path for %s\n", debugstr_a(buffer)); @@ -668,8 +691,7 @@ static void *import_nsfilenames_to_hdrop(CFDataRef data, size_t *ret_size) done: if (paths) { - for (i = 0; i < count; i++) - HeapFree(GetProcessHeap(), 0, paths[i]); + for (i = 0; i < count; i++) free(paths[i]); HeapFree(GetProcessHeap(), 0, paths); } HeapFree(GetProcessHeap(), 0, buffer);
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/clipboard.c | 81 ++++++++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 3 deletions(-)
diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c index 93706680470..cdb4e5e02a8 100644 --- a/dlls/winemac.drv/clipboard.c +++ b/dlls/winemac.drv/clipboard.c @@ -24,6 +24,8 @@
#include "config.h"
+#include "ntstatus.h" +#define WIN32_NO_STATUS #include "macdrv.h" #include "winuser.h" #include "shellapi.h" @@ -588,6 +590,78 @@ static WCHAR *get_dos_file_name(const char *path) }
+/*********************************************************************** + * get_nt_pathname + * + * Simplified version of RtlDosPathNameToNtPathName_U. + */ +static BOOL get_nt_pathname(const WCHAR *name, UNICODE_STRING *nt_name) +{ + static const WCHAR ntprefixW[] = {'\','?','?','\'}; + static const WCHAR uncprefixW[] = {'U','N','C','\'}; + size_t len = lstrlenW(name); + WCHAR *ptr; + + nt_name->MaximumLength = (len + 8) * sizeof(WCHAR); + if (!(ptr = malloc(nt_name->MaximumLength))) return FALSE; + nt_name->Buffer = ptr; + + memcpy(ptr, ntprefixW, sizeof(ntprefixW)); + ptr += ARRAYSIZE(ntprefixW); + if (name[0] == '\' && name[1] == '\') + { + if ((name[2] == '.' || name[2] == '?') && name[3] == '\') + { + name += 4; + len -= 4; + } + else + { + memcpy(ptr, uncprefixW, sizeof(uncprefixW)); + ptr += ARRAYSIZE(uncprefixW); + name += 2; + len -= 2; + } + } + memcpy(ptr, name, (len + 1) * sizeof(WCHAR)); + ptr += len; + nt_name->Length = (ptr - nt_name->Buffer) * sizeof(WCHAR); + return TRUE; +} + + +/* based on wine_get_unix_file_name */ +static char *get_unix_file_name(const WCHAR *dosW) +{ + UNICODE_STRING nt_name; + OBJECT_ATTRIBUTES attr; + NTSTATUS status; + ULONG size = 256; + char *buffer; + + if (!get_nt_pathname(dosW, &nt_name)) return NULL; + InitializeObjectAttributes(&attr, &nt_name, 0, 0, NULL); + for (;;) + { + if (!(buffer = malloc(size))) + { + free(nt_name.Buffer); + return NULL; + } + status = wine_nt_to_unix_file_name(&attr, buffer, &size, FILE_OPEN_IF); + if (status != STATUS_BUFFER_TOO_SMALL) break; + free(buffer); + } + free(nt_name.Buffer); + if (status) + { + free(buffer); + return NULL; + } + return buffer; +} + + /************************************************************************** * import_nsfilenames_to_hdrop * @@ -861,7 +935,7 @@ static CFDataRef export_hdrop_to_filenames(void *data, size_t size) TRACE(" %s\n", dropfiles->fWide ? debugstr_w(p) : debugstr_a(p));
if (dropfiles->fWide) - unixname = wine_get_unix_file_name(p); + unixname = get_unix_file_name(p); else { int len = MultiByteToWideChar(CP_ACP, 0, p, -1, NULL, 0); @@ -875,7 +949,7 @@ static CFDataRef export_hdrop_to_filenames(void *data, size_t size) }
MultiByteToWideChar(CP_ACP, 0, p, -1, buffer, buffer_len); - unixname = wine_get_unix_file_name(buffer); + unixname = get_unix_file_name(buffer); } else unixname = NULL; @@ -893,13 +967,14 @@ static CFDataRef export_hdrop_to_filenames(void *data, size_t size) p = (char*)p + strlen(p) + 1;
filename = CFStringCreateWithFileSystemRepresentation(NULL, unixname); - HeapFree(GetProcessHeap(), 0, unixname); if (!filename) { WARN("failed to create CFString from Unix path %s\n", debugstr_a(unixname)); + free(unixname); goto done; }
+ free(unixname); CFArrayAppendValue(filenames, filename); CFRelease(filename); }
From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@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); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=115553
Your paranoid android.
=== debian11 (build log) ===
error: patch failed: dlls/winemac.drv/clipboard.c:253 error: patch failed: dlls/winemac.drv/display.c:264 error: patch failed: dlls/winemac.drv/gdi.c:157 error: patch failed: dlls/winemac.drv/keyboard.c:530 error: patch failed: dlls/winemac.drv/macdrv_main.c:487 error: patch failed: dlls/winemac.drv/mouse.c:282 error: patch failed: dlls/winemac.drv/opengl.c:1164 error: patch failed: dlls/winemac.drv/surface.c:77 error: patch failed: dlls/winemac.drv/vulkan.c:29 error: patch failed: dlls/winemac.drv/window.c:238 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: dlls/winemac.drv/clipboard.c:253 error: patch failed: dlls/winemac.drv/display.c:264 error: patch failed: dlls/winemac.drv/gdi.c:157 error: patch failed: dlls/winemac.drv/keyboard.c:530 error: patch failed: dlls/winemac.drv/macdrv_main.c:487 error: patch failed: dlls/winemac.drv/mouse.c:282 error: patch failed: dlls/winemac.drv/opengl.c:1164 error: patch failed: dlls/winemac.drv/surface.c:77 error: patch failed: dlls/winemac.drv/vulkan.c:29 error: patch failed: dlls/winemac.drv/window.c:238 Task: Patch failed to apply
From: Jacek Caban jacek@codeweavers.com
Also fixes null termination tests in test_key_names.
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/keyboard.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/dlls/winemac.drv/keyboard.c b/dlls/winemac.drv/keyboard.c index d3e9dca9055..08c76eb1389 100644 --- a/dlls/winemac.drv/keyboard.c +++ b/dlls/winemac.drv/keyboard.c @@ -1257,8 +1257,9 @@ INT macdrv_GetKeyNameText(LONG lparam, LPWSTR buffer, INT size) { if (vkey_names[i].vkey == vkey) { - len = MultiByteToWideChar(CP_UTF8, 0, vkey_names[i].name, -1, buffer, size); - if (len) len--; + len = min(strlen(vkey_names[i].name) + 1, size); + ascii_to_unicode(buffer, vkey_names[i].name, len); + if (len) buffer[--len] = 0; break; } }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=115554
Your paranoid android.
=== debian11 (build log) ===
error: patch failed: dlls/winemac.drv/clipboard.c:253 error: patch failed: dlls/winemac.drv/display.c:264 error: patch failed: dlls/winemac.drv/gdi.c:157 error: patch failed: dlls/winemac.drv/keyboard.c:530 error: patch failed: dlls/winemac.drv/macdrv_main.c:487 error: patch failed: dlls/winemac.drv/mouse.c:282 error: patch failed: dlls/winemac.drv/opengl.c:1164 error: patch failed: dlls/winemac.drv/surface.c:77 error: patch failed: dlls/winemac.drv/vulkan.c:29 error: patch failed: dlls/winemac.drv/window.c:238 error: patch failed: dlls/winemac.drv/keyboard.c:1257 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: dlls/winemac.drv/clipboard.c:253 error: patch failed: dlls/winemac.drv/display.c:264 error: patch failed: dlls/winemac.drv/gdi.c:157 error: patch failed: dlls/winemac.drv/keyboard.c:530 error: patch failed: dlls/winemac.drv/macdrv_main.c:487 error: patch failed: dlls/winemac.drv/mouse.c:282 error: patch failed: dlls/winemac.drv/opengl.c:1164 error: patch failed: dlls/winemac.drv/surface.c:77 error: patch failed: dlls/winemac.drv/vulkan.c:29 error: patch failed: dlls/winemac.drv/window.c:238 error: patch failed: dlls/winemac.drv/keyboard.c:1257 Task: Patch failed to apply
This merge request was approved by Huw Davies.