Commit 35a6148a authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winebus.sys: Use Rtl heap functions.

parent 0017b5eb
...@@ -168,7 +168,7 @@ static NTSTATUS iohid_device_start(struct unix_device *iface) ...@@ -168,7 +168,7 @@ static NTSTATUS iohid_device_start(struct unix_device *iface)
num = IOHIDDeviceGetProperty(private->device, CFSTR(kIOHIDMaxInputReportSizeKey)); num = IOHIDDeviceGetProperty(private->device, CFSTR(kIOHIDMaxInputReportSizeKey));
length = CFNumberToDWORD(num); length = CFNumberToDWORD(num);
private->buffer = HeapAlloc(GetProcessHeap(), 0, length); private->buffer = RtlAllocateHeap(GetProcessHeap(), 0, length);
IOHIDDeviceRegisterInputReportCallback(private->device, private->buffer, length, handle_IOHIDDeviceIOHIDReportCallback, iface); IOHIDDeviceRegisterInputReportCallback(private->device, private->buffer, length, handle_IOHIDDeviceIOHIDReportCallback, iface);
return STATUS_SUCCESS; return STATUS_SUCCESS;
......
...@@ -370,7 +370,7 @@ static NTSTATUS build_report_descriptor(struct platform_private *ext) ...@@ -370,7 +370,7 @@ static NTSTATUS build_report_descriptor(struct platform_private *ext)
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
ext->buffer_length = report_size; ext->buffer_length = report_size;
if (!(ext->report_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, report_size))) if (!(ext->report_buffer = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, report_size)))
goto failed; goto failed;
/* Initialize axis in the report */ /* Initialize axis in the report */
...@@ -382,7 +382,7 @@ static NTSTATUS build_report_descriptor(struct platform_private *ext) ...@@ -382,7 +382,7 @@ static NTSTATUS build_report_descriptor(struct platform_private *ext)
return STATUS_SUCCESS; return STATUS_SUCCESS;
failed: failed:
HeapFree(GetProcessHeap(), 0, ext->report_buffer); RtlFreeHeap(GetProcessHeap(), 0, ext->report_buffer);
hid_descriptor_free(&ext->desc); hid_descriptor_free(&ext->desc);
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
} }
...@@ -471,7 +471,7 @@ static NTSTATUS build_mapped_report_descriptor(struct platform_private *ext) ...@@ -471,7 +471,7 @@ static NTSTATUS build_mapped_report_descriptor(struct platform_private *ext)
if (!hid_descriptor_end(&ext->desc)) if (!hid_descriptor_end(&ext->desc))
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
if (!(ext->report_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ext->buffer_length))) if (!(ext->report_buffer = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, ext->buffer_length)))
goto failed; goto failed;
/* Initialize axis in the report */ /* Initialize axis in the report */
...@@ -487,7 +487,7 @@ static NTSTATUS build_mapped_report_descriptor(struct platform_private *ext) ...@@ -487,7 +487,7 @@ static NTSTATUS build_mapped_report_descriptor(struct platform_private *ext)
return STATUS_SUCCESS; return STATUS_SUCCESS;
failed: failed:
HeapFree(GetProcessHeap(), 0, ext->report_buffer); RtlFreeHeap(GetProcessHeap(), 0, ext->report_buffer);
hid_descriptor_free(&ext->desc); hid_descriptor_free(&ext->desc);
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
} }
......
...@@ -544,9 +544,9 @@ static NTSTATUS build_report_descriptor(struct wine_input_private *ext, struct u ...@@ -544,9 +544,9 @@ static NTSTATUS build_report_descriptor(struct wine_input_private *ext, struct u
TRACE("Report will be %i bytes\n", report_size); TRACE("Report will be %i bytes\n", report_size);
ext->buffer_length = report_size; ext->buffer_length = report_size;
if (!(ext->current_report_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, report_size))) if (!(ext->current_report_buffer = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, report_size)))
goto failed; goto failed;
if (!(ext->last_report_buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, report_size))) if (!(ext->last_report_buffer = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, report_size)))
goto failed; goto failed;
ext->report_state = FIRST; ext->report_state = FIRST;
...@@ -558,8 +558,8 @@ static NTSTATUS build_report_descriptor(struct wine_input_private *ext, struct u ...@@ -558,8 +558,8 @@ static NTSTATUS build_report_descriptor(struct wine_input_private *ext, struct u
return STATUS_SUCCESS; return STATUS_SUCCESS;
failed: failed:
HeapFree(GetProcessHeap(), 0, ext->current_report_buffer); RtlFreeHeap(GetProcessHeap(), 0, ext->current_report_buffer);
HeapFree(GetProcessHeap(), 0, ext->last_report_buffer); RtlFreeHeap(GetProcessHeap(), 0, ext->last_report_buffer);
hid_descriptor_free(&ext->desc); hid_descriptor_free(&ext->desc);
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
} }
...@@ -807,8 +807,8 @@ static void lnxev_device_destroy(struct unix_device *iface) ...@@ -807,8 +807,8 @@ static void lnxev_device_destroy(struct unix_device *iface)
{ {
struct wine_input_private *ext = input_impl_from_unix_device(iface); struct wine_input_private *ext = input_impl_from_unix_device(iface);
HeapFree(GetProcessHeap(), 0, ext->current_report_buffer); RtlFreeHeap(GetProcessHeap(), 0, ext->current_report_buffer);
HeapFree(GetProcessHeap(), 0, ext->last_report_buffer); RtlFreeHeap(GetProcessHeap(), 0, ext->last_report_buffer);
hid_descriptor_free(&ext->desc); hid_descriptor_free(&ext->desc);
udev_device_unref(ext->base.udev_device); udev_device_unref(ext->base.udev_device);
......
...@@ -36,13 +36,13 @@ static BOOL hid_descriptor_append(struct hid_descriptor *desc, const BYTE *buffe ...@@ -36,13 +36,13 @@ static BOOL hid_descriptor_append(struct hid_descriptor *desc, const BYTE *buffe
if (desc->size + size > desc->max_size) if (desc->size + size > desc->max_size)
{ {
desc->max_size = max(desc->max_size * 3 / 2, desc->size + size); desc->max_size = max(desc->max_size * 3 / 2, desc->size + size);
if (!desc->data) desc->data = HeapAlloc(GetProcessHeap(), 0, desc->max_size); if (!desc->data) desc->data = RtlAllocateHeap(GetProcessHeap(), 0, desc->max_size);
else desc->data = HeapReAlloc(GetProcessHeap(), 0, tmp, desc->max_size); else desc->data = RtlReAllocateHeap(GetProcessHeap(), 0, tmp, desc->max_size);
} }
if (!desc->data) if (!desc->data)
{ {
HeapFree(GetProcessHeap(), 0, tmp); RtlFreeHeap(GetProcessHeap(), 0, tmp);
return FALSE; return FALSE;
} }
...@@ -89,7 +89,7 @@ BOOL hid_descriptor_end(struct hid_descriptor *desc) ...@@ -89,7 +89,7 @@ BOOL hid_descriptor_end(struct hid_descriptor *desc)
void hid_descriptor_free(struct hid_descriptor *desc) void hid_descriptor_free(struct hid_descriptor *desc)
{ {
HeapFree(GetProcessHeap(), 0, desc->data); RtlFreeHeap(GetProcessHeap(), 0, desc->data);
} }
BOOL hid_descriptor_add_buttons(struct hid_descriptor *desc, USAGE usage_page, BOOL hid_descriptor_add_buttons(struct hid_descriptor *desc, USAGE usage_page,
......
...@@ -418,8 +418,8 @@ static void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length ...@@ -418,8 +418,8 @@ static void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length
EnterCriticalSection(&ext->cs); EnterCriticalSection(&ext->cs);
if (length > ext->buffer_size) if (length > ext->buffer_size)
{ {
HeapFree(GetProcessHeap(), 0, ext->last_report); RtlFreeHeap(GetProcessHeap(), 0, ext->last_report);
ext->last_report = HeapAlloc(GetProcessHeap(), 0, length); ext->last_report = RtlAllocateHeap(GetProcessHeap(), 0, length);
if (!ext->last_report) if (!ext->last_report)
{ {
ERR_(hid_report)("Failed to alloc last report\n"); ERR_(hid_report)("Failed to alloc last report\n");
...@@ -592,7 +592,7 @@ static DWORD CALLBACK bus_main_thread(void *args) ...@@ -592,7 +592,7 @@ static DWORD CALLBACK bus_main_thread(void *args)
if (status) WARN("%s bus wait returned status %#x\n", debugstr_w(bus.name), status); if (status) WARN("%s bus wait returned status %#x\n", debugstr_w(bus.name), status);
else TRACE("%s main loop exited\n", debugstr_w(bus.name)); else TRACE("%s main loop exited\n", debugstr_w(bus.name));
HeapFree(GetProcessHeap(), 0, bus.bus_event); RtlFreeHeap(GetProcessHeap(), 0, bus.bus_event);
return status; return status;
} }
...@@ -608,7 +608,7 @@ static NTSTATUS bus_main_thread_start(struct bus_main_params *bus) ...@@ -608,7 +608,7 @@ static NTSTATUS bus_main_thread_start(struct bus_main_params *bus)
} }
max_size = offsetof(struct bus_event, input_report.buffer[0x10000]); max_size = offsetof(struct bus_event, input_report.buffer[0x10000]);
if (!(bus->bus_event = HeapAlloc(GetProcessHeap(), 0, max_size))) if (!(bus->bus_event = RtlAllocateHeap(GetProcessHeap(), 0, max_size)))
{ {
ERR("failed to allocate %s bus event.\n", debugstr_w(bus->name)); ERR("failed to allocate %s bus event.\n", debugstr_w(bus->name));
CloseHandle(bus->init_done); CloseHandle(bus->init_done);
...@@ -634,8 +634,8 @@ static void sdl_bus_free_mappings(struct sdl_bus_options *options) ...@@ -634,8 +634,8 @@ static void sdl_bus_free_mappings(struct sdl_bus_options *options)
DWORD count = options->mappings_count; DWORD count = options->mappings_count;
char **mappings = options->mappings; char **mappings = options->mappings;
while (count) HeapFree(GetProcessHeap(), 0, mappings[--count]); while (count) RtlFreeHeap(GetProcessHeap(), 0, mappings[--count]);
HeapFree(GetProcessHeap(), 0, mappings); RtlFreeHeap(GetProcessHeap(), 0, mappings);
} }
static void sdl_bus_load_mappings(struct sdl_bus_options *options) static void sdl_bus_load_mappings(struct sdl_bus_options *options)
...@@ -659,9 +659,9 @@ static void sdl_bus_load_mappings(struct sdl_bus_options *options) ...@@ -659,9 +659,9 @@ static void sdl_bus_load_mappings(struct sdl_bus_options *options)
if (status) return; if (status) return;
capacity = 1024; capacity = 1024;
mappings = HeapAlloc(GetProcessHeap(), 0, capacity * sizeof(*mappings)); mappings = RtlAllocateHeap(GetProcessHeap(), 0, capacity * sizeof(*mappings));
info_max_size = offsetof(KEY_VALUE_FULL_INFORMATION, Name) + 512; info_max_size = offsetof(KEY_VALUE_FULL_INFORMATION, Name) + 512;
info = HeapAlloc(GetProcessHeap(), 0, info_max_size); info = RtlAllocateHeap(GetProcessHeap(), 0, info_max_size);
while (!status && info && mappings) while (!status && info && mappings)
{ {
...@@ -669,7 +669,7 @@ static void sdl_bus_load_mappings(struct sdl_bus_options *options) ...@@ -669,7 +669,7 @@ static void sdl_bus_load_mappings(struct sdl_bus_options *options)
while (status == STATUS_BUFFER_OVERFLOW) while (status == STATUS_BUFFER_OVERFLOW)
{ {
info_max_size = info_size; info_max_size = info_size;
if (!(info = HeapReAlloc(GetProcessHeap(), 0, info, info_max_size))) break; if (!(info = RtlReAllocateHeap(GetProcessHeap(), 0, info, info_max_size))) break;
status = NtEnumerateValueKey(key, idx, KeyValueFullInformation, info, info_max_size, &info_size); status = NtEnumerateValueKey(key, idx, KeyValueFullInformation, info, info_max_size, &info_size);
} }
...@@ -687,11 +687,11 @@ static void sdl_bus_load_mappings(struct sdl_bus_options *options) ...@@ -687,11 +687,11 @@ static void sdl_bus_load_mappings(struct sdl_bus_options *options)
RtlUnicodeToMultiByteSize(&len, (WCHAR *)((char *)info + info->DataOffset), info_size - info->DataOffset); RtlUnicodeToMultiByteSize(&len, (WCHAR *)((char *)info + info->DataOffset), info_size - info->DataOffset);
if (!len) continue; if (!len) continue;
if (!(mappings[count++] = HeapAlloc(GetProcessHeap(), 0, len + 1))) break; if (!(mappings[count++] = RtlAllocateHeap(GetProcessHeap(), 0, len + 1))) break;
if (count > capacity) if (count > capacity)
{ {
capacity = capacity * 3 / 2; capacity = capacity * 3 / 2;
if (!(mappings = HeapReAlloc(GetProcessHeap(), 0, mappings, capacity * sizeof(*mappings)))) if (!(mappings = RtlReAllocateHeap(GetProcessHeap(), 0, mappings, capacity * sizeof(*mappings))))
break; break;
} }
...@@ -700,11 +700,11 @@ static void sdl_bus_load_mappings(struct sdl_bus_options *options) ...@@ -700,11 +700,11 @@ static void sdl_bus_load_mappings(struct sdl_bus_options *options)
if (mappings[len - 1]) mappings[len] = 0; if (mappings[len - 1]) mappings[len] = 0;
} }
if (mappings) while (count) HeapFree(GetProcessHeap(), 0, mappings[--count]); if (mappings) while (count) RtlFreeHeap(GetProcessHeap(), 0, mappings[--count]);
HeapFree(GetProcessHeap(), 0, mappings); RtlFreeHeap(GetProcessHeap(), 0, mappings);
done: done:
HeapFree(GetProcessHeap(), 0, info); RtlFreeHeap(GetProcessHeap(), 0, info);
NtClose(key); NtClose(key);
} }
...@@ -864,7 +864,7 @@ static NTSTATUS pdo_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp) ...@@ -864,7 +864,7 @@ static NTSTATUS pdo_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp)
ext->cs.DebugInfo->Spare[0] = 0; ext->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&ext->cs); DeleteCriticalSection(&ext->cs);
HeapFree(GetProcessHeap(), 0, ext->last_report); RtlFreeHeap(GetProcessHeap(), 0, ext->last_report);
irp->IoStatus.Status = STATUS_SUCCESS; irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(irp, IO_NO_INCREMENT); IoCompleteRequest(irp, IO_NO_INCREMENT);
......
...@@ -253,7 +253,7 @@ void *unix_device_create(const struct unix_device_vtbl *vtbl, SIZE_T size) ...@@ -253,7 +253,7 @@ void *unix_device_create(const struct unix_device_vtbl *vtbl, SIZE_T size)
{ {
struct unix_device *iface; struct unix_device *iface;
if (!(iface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size))) return NULL; if (!(iface = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, size))) return NULL;
iface->vtbl = vtbl; iface->vtbl = vtbl;
iface->ref = 1; iface->ref = 1;
...@@ -265,7 +265,7 @@ static void unix_device_decref(struct unix_device *iface) ...@@ -265,7 +265,7 @@ static void unix_device_decref(struct unix_device *iface)
if (!InterlockedDecrement(&iface->ref)) if (!InterlockedDecrement(&iface->ref))
{ {
iface->vtbl->destroy(iface); iface->vtbl->destroy(iface);
HeapFree(GetProcessHeap(), 0, iface); RtlFreeHeap(GetProcessHeap(), 0, iface);
} }
} }
...@@ -353,14 +353,14 @@ void bus_event_queue_destroy(struct list *queue) ...@@ -353,14 +353,14 @@ void bus_event_queue_destroy(struct list *queue)
LIST_FOR_EACH_ENTRY_SAFE(event, next, queue, struct bus_event, entry) LIST_FOR_EACH_ENTRY_SAFE(event, next, queue, struct bus_event, entry)
{ {
bus_event_cleanup(event); bus_event_cleanup(event);
HeapFree(GetProcessHeap(), 0, event); RtlFreeHeap(GetProcessHeap(), 0, event);
} }
} }
BOOL bus_event_queue_device_removed(struct list *queue, struct unix_device *device) BOOL bus_event_queue_device_removed(struct list *queue, struct unix_device *device)
{ {
ULONG size = sizeof(struct bus_event); ULONG size = sizeof(struct bus_event);
struct bus_event *event = HeapAlloc(GetProcessHeap(), 0, size); struct bus_event *event = RtlAllocateHeap(GetProcessHeap(), 0, size);
if (!event) return FALSE; if (!event) return FALSE;
if (unix_device_incref(device) == 1) return FALSE; /* being destroyed */ if (unix_device_incref(device) == 1) return FALSE; /* being destroyed */
...@@ -375,7 +375,7 @@ BOOL bus_event_queue_device_removed(struct list *queue, struct unix_device *devi ...@@ -375,7 +375,7 @@ BOOL bus_event_queue_device_removed(struct list *queue, struct unix_device *devi
BOOL bus_event_queue_device_created(struct list *queue, struct unix_device *device, struct device_desc *desc) BOOL bus_event_queue_device_created(struct list *queue, struct unix_device *device, struct device_desc *desc)
{ {
ULONG size = sizeof(struct bus_event); ULONG size = sizeof(struct bus_event);
struct bus_event *event = HeapAlloc(GetProcessHeap(), 0, size); struct bus_event *event = RtlAllocateHeap(GetProcessHeap(), 0, size);
if (!event) return FALSE; if (!event) return FALSE;
if (unix_device_incref(device) == 1) return FALSE; /* being destroyed */ if (unix_device_incref(device) == 1) return FALSE; /* being destroyed */
...@@ -391,7 +391,7 @@ BOOL bus_event_queue_device_created(struct list *queue, struct unix_device *devi ...@@ -391,7 +391,7 @@ BOOL bus_event_queue_device_created(struct list *queue, struct unix_device *devi
BOOL bus_event_queue_input_report(struct list *queue, struct unix_device *device, BYTE *report, USHORT length) BOOL bus_event_queue_input_report(struct list *queue, struct unix_device *device, BYTE *report, USHORT length)
{ {
ULONG size = offsetof(struct bus_event, input_report.buffer[length]); ULONG size = offsetof(struct bus_event, input_report.buffer[length]);
struct bus_event *event = HeapAlloc(GetProcessHeap(), 0, size); struct bus_event *event = RtlAllocateHeap(GetProcessHeap(), 0, size);
if (!event) return FALSE; if (!event) return FALSE;
if (unix_device_incref(device) == 1) return FALSE; /* being destroyed */ if (unix_device_incref(device) == 1) return FALSE; /* being destroyed */
...@@ -420,7 +420,7 @@ BOOL bus_event_queue_pop(struct list *queue, struct bus_event *event) ...@@ -420,7 +420,7 @@ BOOL bus_event_queue_pop(struct list *queue, struct bus_event *event)
else size = offsetof(struct bus_event, input_report.buffer[event->input_report.length]); else size = offsetof(struct bus_event, input_report.buffer[event->input_report.length]);
memcpy(event, tmp, size); memcpy(event, tmp, size);
HeapFree(GetProcessHeap(), 0, tmp); RtlFreeHeap(GetProcessHeap(), 0, tmp);
return TRUE; return TRUE;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment