Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
8f6932fd
Commit
8f6932fd
authored
Sep 17, 2021
by
Rémi Bernon
Committed by
Alexandre Julliard
Sep 17, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winebus.sys: Avoid process heap allocations on the unix side.
Signed-off-by:
Rémi Bernon
<
rbernon@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
e54ff70e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
26 deletions
+24
-26
bus_iohid.c
dlls/winebus.sys/bus_iohid.c
+1
-1
bus_sdl.c
dlls/winebus.sys/bus_sdl.c
+4
-6
bus_udev.c
dlls/winebus.sys/bus_udev.c
+6
-8
hid.c
dlls/winebus.sys/hid.c
+4
-4
unixlib.c
dlls/winebus.sys/unixlib.c
+9
-7
No files found.
dlls/winebus.sys/bus_iohid.c
View file @
8f6932fd
...
...
@@ -172,7 +172,7 @@ static NTSTATUS iohid_device_start(struct unix_device *iface)
num
=
IOHIDDeviceGetProperty
(
private
->
device
,
CFSTR
(
kIOHIDMaxInputReportSizeKey
));
length
=
CFNumberToDWORD
(
num
);
private
->
buffer
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
length
);
private
->
buffer
=
malloc
(
length
);
IOHIDDeviceRegisterInputReportCallback
(
private
->
device
,
private
->
buffer
,
length
,
handle_IOHIDDeviceIOHIDReportCallback
,
iface
);
return
STATUS_SUCCESS
;
...
...
dlls/winebus.sys/bus_sdl.c
View file @
8f6932fd
...
...
@@ -374,8 +374,7 @@ static NTSTATUS build_report_descriptor(struct platform_private *ext)
return
STATUS_NO_MEMORY
;
ext
->
buffer_length
=
report_size
;
if
(
!
(
ext
->
report_buffer
=
RtlAllocateHeap
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
report_size
)))
goto
failed
;
if
(
!
(
ext
->
report_buffer
=
calloc
(
1
,
report_size
)))
goto
failed
;
/* Initialize axis in the report */
for
(
i
=
0
;
i
<
axis_count
;
i
++
)
...
...
@@ -386,7 +385,7 @@ static NTSTATUS build_report_descriptor(struct platform_private *ext)
return
STATUS_SUCCESS
;
failed:
RtlFreeHeap
(
GetProcessHeap
(),
0
,
ext
->
report_buffer
);
free
(
ext
->
report_buffer
);
hid_descriptor_free
(
&
ext
->
desc
);
return
STATUS_NO_MEMORY
;
}
...
...
@@ -475,8 +474,7 @@ static NTSTATUS build_mapped_report_descriptor(struct platform_private *ext)
if
(
!
hid_descriptor_end
(
&
ext
->
desc
))
return
STATUS_NO_MEMORY
;
if
(
!
(
ext
->
report_buffer
=
RtlAllocateHeap
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
ext
->
buffer_length
)))
goto
failed
;
if
(
!
(
ext
->
report_buffer
=
calloc
(
1
,
ext
->
buffer_length
)))
goto
failed
;
/* Initialize axis in the report */
for
(
i
=
SDL_CONTROLLER_AXIS_LEFTX
;
i
<
SDL_CONTROLLER_AXIS_MAX
;
i
++
)
...
...
@@ -491,7 +489,7 @@ static NTSTATUS build_mapped_report_descriptor(struct platform_private *ext)
return
STATUS_SUCCESS
;
failed:
RtlFreeHeap
(
GetProcessHeap
(),
0
,
ext
->
report_buffer
);
free
(
ext
->
report_buffer
);
hid_descriptor_free
(
&
ext
->
desc
);
return
STATUS_NO_MEMORY
;
}
...
...
dlls/winebus.sys/bus_udev.c
View file @
8f6932fd
...
...
@@ -548,10 +548,8 @@ static NTSTATUS build_report_descriptor(struct wine_input_private *ext, struct u
TRACE
(
"Report will be %i bytes
\n
"
,
report_size
);
ext
->
buffer_length
=
report_size
;
if
(
!
(
ext
->
current_report_buffer
=
RtlAllocateHeap
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
report_size
)))
goto
failed
;
if
(
!
(
ext
->
last_report_buffer
=
RtlAllocateHeap
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
report_size
)))
goto
failed
;
if
(
!
(
ext
->
current_report_buffer
=
calloc
(
1
,
report_size
)))
goto
failed
;
if
(
!
(
ext
->
last_report_buffer
=
calloc
(
1
,
report_size
)))
goto
failed
;
ext
->
report_state
=
FIRST
;
/* Initialize axis in the report */
...
...
@@ -562,8 +560,8 @@ static NTSTATUS build_report_descriptor(struct wine_input_private *ext, struct u
return
STATUS_SUCCESS
;
failed:
RtlFreeHeap
(
GetProcessHeap
(),
0
,
ext
->
current_report_buffer
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
ext
->
last_report_buffer
);
free
(
ext
->
current_report_buffer
);
free
(
ext
->
last_report_buffer
);
hid_descriptor_free
(
&
ext
->
desc
);
return
STATUS_NO_MEMORY
;
}
...
...
@@ -811,8 +809,8 @@ static void lnxev_device_destroy(struct unix_device *iface)
{
struct
wine_input_private
*
ext
=
input_impl_from_unix_device
(
iface
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
ext
->
current_report_buffer
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
ext
->
last_report_buffer
);
free
(
ext
->
current_report_buffer
);
free
(
ext
->
last_report_buffer
);
hid_descriptor_free
(
&
ext
->
desc
);
udev_device_unref
(
ext
->
base
.
udev_device
);
...
...
dlls/winebus.sys/hid.c
View file @
8f6932fd
...
...
@@ -23,6 +23,7 @@
#endif
#include <stdarg.h>
#include <stdlib.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
...
...
@@ -40,13 +41,12 @@ static BOOL hid_descriptor_append(struct hid_descriptor *desc, const BYTE *buffe
if
(
desc
->
size
+
size
>
desc
->
max_size
)
{
desc
->
max_size
=
max
(
desc
->
max_size
*
3
/
2
,
desc
->
size
+
size
);
if
(
!
desc
->
data
)
desc
->
data
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
desc
->
max_size
);
else
desc
->
data
=
RtlReAllocateHeap
(
GetProcessHeap
(),
0
,
tmp
,
desc
->
max_size
);
desc
->
data
=
realloc
(
tmp
,
desc
->
max_size
);
}
if
(
!
desc
->
data
)
{
RtlFreeHeap
(
GetProcessHeap
(),
0
,
tmp
);
free
(
tmp
);
return
FALSE
;
}
...
...
@@ -93,7 +93,7 @@ BOOL hid_descriptor_end(struct hid_descriptor *desc)
void
hid_descriptor_free
(
struct
hid_descriptor
*
desc
)
{
RtlFreeHeap
(
GetProcessHeap
(),
0
,
desc
->
data
);
free
(
desc
->
data
);
}
BOOL
hid_descriptor_add_buttons
(
struct
hid_descriptor
*
desc
,
USAGE
usage_page
,
...
...
dlls/winebus.sys/unixlib.c
View file @
8f6932fd
...
...
@@ -23,6 +23,8 @@
#include "config.h"
#include <stdarg.h>
#include <stdlib.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
...
...
@@ -257,7 +259,7 @@ void *unix_device_create(const struct unix_device_vtbl *vtbl, SIZE_T size)
{
struct
unix_device
*
iface
;
if
(
!
(
iface
=
RtlAllocateHeap
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
size
)))
return
NULL
;
if
(
!
(
iface
=
calloc
(
1
,
size
)))
return
NULL
;
iface
->
vtbl
=
vtbl
;
iface
->
ref
=
1
;
...
...
@@ -269,7 +271,7 @@ static void unix_device_decref(struct unix_device *iface)
if
(
!
InterlockedDecrement
(
&
iface
->
ref
))
{
iface
->
vtbl
->
destroy
(
iface
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
iface
);
free
(
iface
);
}
}
...
...
@@ -357,14 +359,14 @@ void bus_event_queue_destroy(struct list *queue)
LIST_FOR_EACH_ENTRY_SAFE
(
event
,
next
,
queue
,
struct
bus_event
,
entry
)
{
bus_event_cleanup
(
event
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
event
);
free
(
event
);
}
}
BOOL
bus_event_queue_device_removed
(
struct
list
*
queue
,
struct
unix_device
*
device
)
{
ULONG
size
=
sizeof
(
struct
bus_event
);
struct
bus_event
*
event
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
size
);
struct
bus_event
*
event
=
malloc
(
size
);
if
(
!
event
)
return
FALSE
;
if
(
unix_device_incref
(
device
)
==
1
)
return
FALSE
;
/* being destroyed */
...
...
@@ -379,7 +381,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
)
{
ULONG
size
=
sizeof
(
struct
bus_event
);
struct
bus_event
*
event
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
size
);
struct
bus_event
*
event
=
malloc
(
size
);
if
(
!
event
)
return
FALSE
;
if
(
unix_device_incref
(
device
)
==
1
)
return
FALSE
;
/* being destroyed */
...
...
@@ -395,7 +397,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
)
{
ULONG
size
=
offsetof
(
struct
bus_event
,
input_report
.
buffer
[
length
]);
struct
bus_event
*
event
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
size
);
struct
bus_event
*
event
=
malloc
(
size
);
if
(
!
event
)
return
FALSE
;
if
(
unix_device_incref
(
device
)
==
1
)
return
FALSE
;
/* being destroyed */
...
...
@@ -424,7 +426,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
]);
memcpy
(
event
,
tmp
,
size
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
tmp
);
free
(
tmp
);
return
TRUE
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment