[Spice-devel] [PATCH spice-server 2/2] inputs-channel: Avoid some allocation using RedsState pointer
Frediano Ziglio
fziglio at redhat.com
Thu Nov 30 12:03:08 UTC 2017
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
server/inputs-channel.c | 21 +++++----------------
1 file changed, 5 insertions(+), 16 deletions(-)
diff --git a/server/inputs-channel.c b/server/inputs-channel.c
index 464ac21e..8e9eae49 100644
--- a/server/inputs-channel.c
+++ b/server/inputs-channel.c
@@ -87,34 +87,23 @@ RedsState* spice_kbd_state_get_server(SpiceKbdState *dev)
return dev->reds;
}
-struct SpiceMouseState {
- int dummy;
-};
-
-static SpiceMouseState* spice_mouse_state_new(void)
+static SpiceMouseState* spice_mouse_state_new(RedsState *reds)
{
- return g_new0(SpiceMouseState, 1);
+ return (SpiceMouseState*) reds;
}
-struct SpiceTabletState {
- RedsState *reds;
-};
-
static SpiceTabletState* spice_tablet_state_new(RedsState* reds)
{
- SpiceTabletState *st = g_new0(SpiceTabletState, 1);
- st->reds = reds;
- return st;
+ return (SpiceTabletState*) reds;
}
static void spice_tablet_state_free(SpiceTabletState* st)
{
- g_free(st);
}
RedsState* spice_tablet_state_get_server(SpiceTabletState *st)
{
- return st->reds;
+ return (RedsState*) st;
}
typedef struct RedKeyModifiersPipeItem {
@@ -631,7 +620,7 @@ int inputs_channel_set_mouse(InputsChannel *inputs, SpiceMouseInstance *mouse)
return -1;
}
inputs->mouse = mouse;
- inputs->mouse->st = spice_mouse_state_new();
+ inputs->mouse->st = spice_mouse_state_new(red_channel_get_server(RED_CHANNEL(inputs)));
return 0;
}
--
2.14.3
More information about the Spice-devel
mailing list