[Spice-commits] 5 commits - gtk/channel-cursor.c gtk/channel-display.c gtk/channel-display-mjpeg.c gtk/channel-main.c gtk/channel-record.c gtk/channel-smartcard.c gtk/channel-webdav.c gtk/controller gtk/decode-glz.c gtk/decode-jpeg.c gtk/decode-zlib.c gtk/smartcard-manager.c gtk/spice-channel.c gtk/spice-client-glib-usb-acl-helper.c gtk/spice-client-gtk.override gtk/spice-gstaudio.c gtk/spice-pulse.c gtk/spice-session.c gtk/spice-widget.c gtk/spice-widget-cairo.c gtk/spice-widget-x11.c gtk/spicy.c gtk/spicy-screenshot.c gtk/spicy-stats.c gtk/usb-device-manager.c spice-common
Marc-André Lureau
elmarco at kemper.freedesktop.org
Wed Jul 23 09:51:14 PDT 2014
gtk/channel-cursor.c | 7 +
gtk/channel-display-mjpeg.c | 8 --
gtk/channel-display.c | 8 +-
gtk/channel-main.c | 12 +--
gtk/channel-record.c | 2
gtk/channel-smartcard.c | 29 +++----
gtk/channel-webdav.c | 4 -
gtk/controller/dump.c | 2
gtk/controller/test.c | 4 -
gtk/decode-glz.c | 10 +-
gtk/decode-jpeg.c | 2
gtk/decode-zlib.c | 2
gtk/smartcard-manager.c | 4 -
gtk/spice-channel.c | 50 +++++++------
gtk/spice-client-glib-usb-acl-helper.c | 2
gtk/spice-client-gtk.override | 7 +
gtk/spice-gstaudio.c | 11 +-
gtk/spice-pulse.c | 39 ++++++----
gtk/spice-session.c | 124 +++++++++++++++++++--------------
gtk/spice-widget-cairo.c | 8 +-
gtk/spice-widget-x11.c | 6 -
gtk/spice-widget.c | 109 ++++++++++++++---------------
gtk/spicy-screenshot.c | 2
gtk/spicy-stats.c | 2
gtk/spicy.c | 2
gtk/usb-device-manager.c | 2
spice-common | 2
27 files changed, 254 insertions(+), 206 deletions(-)
New commits:
commit d944678c52d121746884077379871104ee0ef6c7
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Wed Jul 23 18:51:02 2014 +0200
Update spice-common
diff --git a/spice-common b/spice-common
index 6edeb43..d45b3e2 160000
--- a/spice-common
+++ b/spice-common
@@ -1 +1 @@
-Subproject commit 6edeb43747b6161cbff3bc7c18d221d81f2d3eb9
+Subproject commit d45b3e2765ec130d047020d34985e65fa7fb166b
commit 2c3cf155bb6744d7fd88103f714f67db3c9bd60a
Author: Fabiano Fidêncio <fidencio at redhat.com>
Date: Tue Jul 15 16:07:44 2014 +0200
Don't use _GET_PRIVATE all the time
Let's make use of the priv members in the structs, which are much much
faster. Also, to keep the type-safety, the SPICE_IS_* macros were added
in the public methods affected by this patch.
Patch based on an old patch from Alexander Larsson (alexl at redhat.com).
diff --git a/gtk/channel-cursor.c b/gtk/channel-cursor.c
index ae788dc..e6514a2 100644
--- a/gtk/channel-cursor.c
+++ b/gtk/channel-cursor.c
@@ -88,7 +88,8 @@ static void spice_cursor_channel_init(SpiceCursorChannel *channel)
static void spice_cursor_channel_finalize(GObject *obj)
{
- SpiceCursorChannelPrivate *c = SPICE_CURSOR_CHANNEL_GET_PRIVATE(obj);
+ SpiceCursorChannel *channel = SPICE_CURSOR_CHANNEL(obj);
+ SpiceCursorChannelPrivate *c = channel->priv;
g_clear_pointer(&c->cursors, cache_unref);
diff --git a/gtk/channel-smartcard.c b/gtk/channel-smartcard.c
index 88887a7..d27360c 100644
--- a/gtk/channel-smartcard.c
+++ b/gtk/channel-smartcard.c
@@ -158,7 +158,8 @@ static void spice_smartcard_channel_constructed(GObject *object)
static void spice_smartcard_channel_finalize(GObject *obj)
{
- SpiceSmartcardChannelPrivate *c = SPICE_SMARTCARD_CHANNEL_GET_PRIVATE(obj);
+ SpiceSmartcardChannel *channel = SPICE_SMARTCARD_CHANNEL(obj);
+ SpiceSmartcardChannelPrivate *c = channel->priv;
if (c->pending_card_insertions != NULL) {
g_hash_table_destroy(c->pending_card_insertions);
@@ -187,7 +188,8 @@ static void spice_smartcard_channel_finalize(GObject *obj)
static void spice_smartcard_channel_reset(SpiceChannel *channel, gboolean migrating)
{
- SpiceSmartcardChannelPrivate *c = SPICE_SMARTCARD_CHANNEL_GET_PRIVATE(channel);
+ SpiceSmartcardChannel *smartcard_channel = SPICE_SMARTCARD_CHANNEL(channel);
+ SpiceSmartcardChannelPrivate *c = smartcard_channel->priv;
g_hash_table_remove_all(c->pending_card_insertions);
g_hash_table_remove_all(c->pending_reader_removals);
@@ -476,11 +478,11 @@ static void spice_smartcard_channel_up(SpiceChannel *channel)
static void handle_smartcard_msg(SpiceChannel *channel, SpiceMsgIn *in)
{
#ifdef USE_SMARTCARD
- SpiceSmartcardChannelPrivate *priv = SPICE_SMARTCARD_CHANNEL_GET_PRIVATE(channel);
+ SpiceSmartcardChannel *smartcard_channel = SPICE_SMARTCARD_CHANNEL(channel);
+ SpiceSmartcardChannelPrivate *priv = smartcard_channel->priv;
SpiceMsgSmartcard *msg = spice_msg_in_parsed(in);
VReader *reader;
- priv = SPICE_SMARTCARD_CHANNEL_GET_PRIVATE(channel);
CHANNEL_DEBUG(channel, "handle msg %d", msg->type);
switch (msg->type) {
case VSC_Error:
@@ -497,15 +499,14 @@ static void handle_smartcard_msg(SpiceChannel *channel, SpiceMsgIn *in)
priv->pending_reader_additions);
vreader_set_id(reader, msg->reader_id);
- if (spice_channel_has_pending_card_insertion(SPICE_SMARTCARD_CHANNEL(channel), reader)) {
- send_msg_atr(SPICE_SMARTCARD_CHANNEL(channel), reader);
- spice_channel_drop_pending_card_insertion(SPICE_SMARTCARD_CHANNEL(channel), reader);
+ if (spice_channel_has_pending_card_insertion(smartcard_channel, reader)) {
+ send_msg_atr(smartcard_channel, reader);
+ spice_channel_drop_pending_card_insertion(smartcard_channel, reader);
}
- if (spice_channel_has_pending_reader_removal(SPICE_SMARTCARD_CHANNEL(channel), reader)) {
- send_msg_generic(SPICE_SMARTCARD_CHANNEL(channel),
- reader, VSC_CardRemove);
- spice_channel_drop_pending_reader_removal(SPICE_SMARTCARD_CHANNEL(channel), reader);
+ if (spice_channel_has_pending_reader_removal(smartcard_channel, reader)) {
+ send_msg_generic(smartcard_channel, reader, VSC_CardRemove);
+ spice_channel_drop_pending_reader_removal(smartcard_channel, reader);
}
break;
case VSC_APDU:
@@ -518,7 +519,7 @@ static void handle_smartcard_msg(SpiceChannel *channel, SpiceMsgIn *in)
g_warning("Unexpected message: %d", priv->in_flight_message->message_type);
break;
}
- smartcard_message_complete_in_flight(SPICE_SMARTCARD_CHANNEL(channel));
+ smartcard_message_complete_in_flight(smartcard_channel);
break;
@@ -537,13 +538,13 @@ static void handle_smartcard_msg(SpiceChannel *channel, SpiceMsgIn *in)
msg->data, msg->length,
data_out, &data_out_len);
if (reader_status == VREADER_OK) {
- send_msg_generic_with_data(SPICE_SMARTCARD_CHANNEL(channel),
+ send_msg_generic_with_data(smartcard_channel,
reader, VSC_APDU,
data_out, data_out_len, FALSE);
} else {
uint32_t error_code;
error_code = GUINT32_TO_LE(reader_status);
- send_msg_generic_with_data(SPICE_SMARTCARD_CHANNEL(channel),
+ send_msg_generic_with_data(smartcard_channel,
reader, VSC_Error,
(uint8_t*)&error_code,
sizeof (error_code), FALSE);
diff --git a/gtk/smartcard-manager.c b/gtk/smartcard-manager.c
index 683a47e..9e228e9 100644
--- a/gtk/smartcard-manager.c
+++ b/gtk/smartcard-manager.c
@@ -116,9 +116,9 @@ static void spice_smartcard_manager_dispose(GObject *gobject)
static void spice_smartcard_manager_finalize(GObject *gobject)
{
- SpiceSmartcardManagerPrivate *priv;
+ SpiceSmartcardManager *manager = SPICE_SMARTCARD_MANAGER(gobject);
+ SpiceSmartcardManagerPrivate *priv = manager->priv;
- priv = SPICE_SMARTCARD_MANAGER_GET_PRIVATE(gobject);
if (priv->monitor_id != 0) {
g_source_remove(priv->monitor_id);
priv->monitor_id = 0;
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 521f10a..e875963 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -224,7 +224,7 @@ static void spice_channel_get_property(GObject *gobject,
G_GNUC_INTERNAL
gint spice_channel_get_channel_id(SpiceChannel *channel)
{
- SpiceChannelPrivate *c = SPICE_CHANNEL_GET_PRIVATE(channel);
+ SpiceChannelPrivate *c = channel->priv;
g_return_val_if_fail(c != NULL, 0);
return c->channel_id;
@@ -233,7 +233,7 @@ gint spice_channel_get_channel_id(SpiceChannel *channel)
G_GNUC_INTERNAL
gint spice_channel_get_channel_type(SpiceChannel *channel)
{
- SpiceChannelPrivate *c = SPICE_CHANNEL_GET_PRIVATE(channel);
+ SpiceChannelPrivate *c = channel->priv;
g_return_val_if_fail(c != NULL, 0);
return c->channel_type;
@@ -2493,11 +2493,13 @@ gboolean spice_channel_connect(SpiceChannel *channel)
**/
gboolean spice_channel_open_fd(SpiceChannel *channel, int fd)
{
- SpiceChannelPrivate *c = SPICE_CHANNEL_GET_PRIVATE(channel);
+ SpiceChannelPrivate *c;
- g_return_val_if_fail(c != NULL, FALSE);
+ g_return_val_if_fail(SPICE_IS_CHANNEL(channel), FALSE);
+ g_return_val_if_fail(channel->priv != NULL, FALSE);
g_return_val_if_fail(fd >= -1, FALSE);
+ c = channel->priv;
c->fd = fd;
return channel_connect(channel);
@@ -2506,7 +2508,7 @@ gboolean spice_channel_open_fd(SpiceChannel *channel, int fd)
/* system or coroutine context */
static void channel_reset(SpiceChannel *channel, gboolean migrating)
{
- SpiceChannelPrivate *c = SPICE_CHANNEL_GET_PRIVATE(channel);
+ SpiceChannelPrivate *c = channel->priv;
if (c->connect_delayed_id) {
g_source_remove(c->connect_delayed_id);
@@ -2578,7 +2580,7 @@ void spice_channel_reset(SpiceChannel *channel, gboolean migrating)
/* system or coroutine context */
static void channel_disconnect(SpiceChannel *channel)
{
- SpiceChannelPrivate *c = SPICE_CHANNEL_GET_PRIVATE(channel);
+ SpiceChannelPrivate *c = channel->priv;
g_return_if_fail(c != NULL);
@@ -2607,10 +2609,14 @@ static void channel_disconnect(SpiceChannel *channel)
**/
void spice_channel_disconnect(SpiceChannel *channel, SpiceChannelEvent reason)
{
- SpiceChannelPrivate *c = SPICE_CHANNEL_GET_PRIVATE(channel);
+ SpiceChannelPrivate *c;
CHANNEL_DEBUG(channel, "channel disconnect %d", reason);
- g_return_if_fail(c != NULL);
+
+ g_return_if_fail(SPICE_IS_CHANNEL(channel));
+ g_return_if_fail(channel->priv != NULL);
+
+ c = channel->priv;
if (c->state == SPICE_CHANNEL_STATE_UNCONNECTED)
return;
@@ -2749,8 +2755,8 @@ enum spice_channel_state spice_channel_get_state(SpiceChannel *channel)
G_GNUC_INTERNAL
void spice_channel_swap(SpiceChannel *channel, SpiceChannel *swap, gboolean swap_msgs)
{
- SpiceChannelPrivate *c = SPICE_CHANNEL_GET_PRIVATE(channel);
- SpiceChannelPrivate *s = SPICE_CHANNEL_GET_PRIVATE(swap);
+ SpiceChannelPrivate *c = channel->priv;
+ SpiceChannelPrivate *s = swap->priv;
g_return_if_fail(c != NULL);
g_return_if_fail(s != NULL);
@@ -2811,7 +2817,7 @@ static void spice_channel_handle_msg(SpiceChannel *channel, SpiceMsgIn *msg)
static void spice_channel_reset_capabilities(SpiceChannel *channel)
{
- SpiceChannelPrivate *c = SPICE_CHANNEL_GET_PRIVATE(channel);
+ SpiceChannelPrivate *c = channel->priv;
g_array_set_size(c->caps, 0);
if (SPICE_CHANNEL_GET_CLASS(channel)->channel_reset_capabilities) {
@@ -2821,7 +2827,7 @@ static void spice_channel_reset_capabilities(SpiceChannel *channel)
static void spice_channel_send_migration_handshake(SpiceChannel *channel)
{
- SpiceChannelPrivate *c = SPICE_CHANNEL_GET_PRIVATE(channel);
+ SpiceChannelPrivate *c = channel->priv;
if (SPICE_CHANNEL_GET_CLASS(channel)->channel_send_migration_handshake) {
SPICE_CHANNEL_GET_CLASS(channel)->channel_send_migration_handshake(channel);
diff --git a/gtk/spice-gstaudio.c b/gtk/spice-gstaudio.c
index 4a80889..faa0c74 100644
--- a/gtk/spice-gstaudio.c
+++ b/gtk/spice-gstaudio.c
@@ -81,9 +81,10 @@ void stream_dispose(struct stream *s)
static void spice_gstaudio_dispose(GObject *obj)
{
+ SpiceGstaudio *gstaudio = SPICE_GSTAUDIO(obj);
SpiceGstaudioPrivate *p;
SPICE_DEBUG("%s", __FUNCTION__);
- p = SPICE_GSTAUDIO_GET_PRIVATE(obj);
+ p = gstaudio->priv;
stream_dispose(&p->playback);
stream_dispose(&p->record);
@@ -261,7 +262,7 @@ static void channel_event(SpiceChannel *channel, SpiceChannelEvent event,
static void playback_stop(SpicePlaybackChannel *channel, gpointer data)
{
SpiceGstaudio *gstaudio = data;
- SpiceGstaudioPrivate *p = SPICE_GSTAUDIO_GET_PRIVATE(gstaudio);
+ SpiceGstaudioPrivate *p = gstaudio->priv;
if (p->playback.pipe)
gst_element_set_state(p->playback.pipe, GST_STATE_READY);
@@ -274,7 +275,7 @@ static void playback_stop(SpicePlaybackChannel *channel, gpointer data)
static gboolean update_mmtime_timeout_cb(gpointer data)
{
SpiceGstaudio *gstaudio = data;
- SpiceGstaudioPrivate *p = SPICE_GSTAUDIO_GET_PRIVATE(gstaudio);
+ SpiceGstaudioPrivate *p = gstaudio->priv;
GstQuery *q;
q = gst_query_new_latency();
@@ -296,7 +297,7 @@ static void playback_start(SpicePlaybackChannel *channel, gint format, gint chan
gint frequency, gpointer data)
{
SpiceGstaudio *gstaudio = data;
- SpiceGstaudioPrivate *p = SPICE_GSTAUDIO_GET_PRIVATE(gstaudio);
+ SpiceGstaudioPrivate *p = gstaudio->priv;
g_return_if_fail(p != NULL);
g_return_if_fail(format == SPICE_AUDIO_FMT_S16);
@@ -349,7 +350,7 @@ static void playback_data(SpicePlaybackChannel *channel,
gpointer data)
{
SpiceGstaudio *gstaudio = data;
- SpiceGstaudioPrivate *p = SPICE_GSTAUDIO_GET_PRIVATE(gstaudio);
+ SpiceGstaudioPrivate *p = gstaudio->priv;
GstBuffer *buf;
g_return_if_fail(p != NULL);
diff --git a/gtk/spice-pulse.c b/gtk/spice-pulse.c
index 32d6347..744ce4d 100644
--- a/gtk/spice-pulse.c
+++ b/gtk/spice-pulse.c
@@ -81,9 +81,10 @@ static gboolean connect_channel(SpiceAudio *audio, SpiceChannel *channel);
static void spice_pulse_finalize(GObject *obj)
{
+ SpicePulse *pulse = SPICE_PULSE(obj);
SpicePulsePrivate *p;
- p = SPICE_PULSE_GET_PRIVATE(obj);
+ p = pulse->priv;
if (p->context != NULL)
pa_context_unref(p->context);
@@ -96,10 +97,11 @@ static void spice_pulse_finalize(GObject *obj)
static void spice_pulse_dispose(GObject *obj)
{
+ SpicePulse *pulse = SPICE_PULSE(obj);
SpicePulsePrivate *p;
SPICE_DEBUG("%s", __FUNCTION__);
- p = SPICE_PULSE_GET_PRIVATE(obj);
+ p = pulse->priv;
if (p->playback.uncork_op)
pa_operation_unref(p->playback.uncork_op);
@@ -160,7 +162,7 @@ static void pulse_uncork_cb(pa_stream *pastream, int success, void *data)
static void stream_uncork(SpicePulse *pulse, struct stream *s)
{
- SpicePulsePrivate *p = SPICE_PULSE_GET_PRIVATE(pulse);
+ SpicePulsePrivate *p = pulse->priv;
pa_operation *o = NULL;
g_return_if_fail(s->stream);
@@ -219,7 +221,7 @@ static void pulse_cork_cb(pa_stream *pastream, int success, void *data)
static void stream_cork(SpicePulse *pulse, struct stream *s, gboolean with_flush)
{
- SpicePulsePrivate *p = SPICE_PULSE_GET_PRIVATE(pulse);
+ SpicePulsePrivate *p = pulse->priv;
pa_operation *o = NULL;
if (s->uncork_op) {
@@ -242,7 +244,7 @@ static void stream_cork(SpicePulse *pulse, struct stream *s, gboolean with_flush
static void stream_stop(SpicePulse *pulse, struct stream *s)
{
- SpicePulsePrivate *p = SPICE_PULSE_GET_PRIVATE(pulse);
+ SpicePulsePrivate *p = pulse->priv;
if (pa_stream_disconnect(s->stream) < 0) {
g_warning("pa_stream_disconnect() failed: %s",
@@ -254,8 +256,10 @@ static void stream_stop(SpicePulse *pulse, struct stream *s)
static void stream_state_callback(pa_stream *s, void *userdata)
{
+ SpicePulse *pulse = userdata;
SpicePulsePrivate *p;
- p = SPICE_PULSE_GET_PRIVATE(userdata);
+
+ p = pulse->priv;
g_return_if_fail(p != NULL);
g_return_if_fail(s != NULL);
@@ -273,11 +277,12 @@ static void stream_state_callback(pa_stream *s, void *userdata)
static void stream_underflow_cb(pa_stream *s, void *userdata)
{
+ SpicePulse *pulse = userdata;
SpicePulsePrivate *p;
SPICE_DEBUG("PA stream underflow!!");
- p = SPICE_PULSE_GET_PRIVATE(userdata);
+ p = pulse->priv;
g_return_if_fail(p != NULL);
p->playback.num_underflow++;
#ifdef PULSE_ADJUST_LATENCY
@@ -303,7 +308,7 @@ static void stream_update_latency_callback(pa_stream *s, void *userdata)
int negative = 0;
SpicePulsePrivate *p;
- p = SPICE_PULSE_GET_PRIVATE(pulse);
+ p = pulse->priv;
g_return_if_fail(s != NULL);
g_return_if_fail(p != NULL);
@@ -331,7 +336,7 @@ static void stream_update_latency_callback(pa_stream *s, void *userdata)
static void create_playback(SpicePulse *pulse)
{
- SpicePulsePrivate *p = SPICE_PULSE_GET_PRIVATE(pulse);
+ SpicePulsePrivate *p = pulse->priv;
pa_stream_flags_t flags;
pa_buffer_attr buffer_attr = { 0, };
@@ -364,7 +369,7 @@ static void playback_start(SpicePlaybackChannel *channel, gint format, gint chan
gint frequency, gpointer data)
{
SpicePulse *pulse = data;
- SpicePulsePrivate *p = SPICE_PULSE_GET_PRIVATE(pulse);
+ SpicePulsePrivate *p = pulse->priv;
pa_context_state_t state;
guint latency;
@@ -414,7 +419,7 @@ static void playback_data(SpicePlaybackChannel *channel,
gpointer data)
{
SpicePulse *pulse = data;
- SpicePulsePrivate *p = SPICE_PULSE_GET_PRIVATE(pulse);
+ SpicePulsePrivate *p = pulse->priv;
pa_stream_state_t state;
if (!p->playback.stream)
@@ -461,7 +466,7 @@ static void playback_stop(SpicePlaybackChannel *channel, gpointer data)
static void stream_read_callback(pa_stream *s, size_t length, void *data)
{
SpicePulse *pulse = data;
- SpicePulsePrivate *p = SPICE_PULSE_GET_PRIVATE(pulse);
+ SpicePulsePrivate *p = pulse->priv;
g_return_if_fail(p != NULL);
@@ -493,7 +498,7 @@ static void stream_read_callback(pa_stream *s, size_t length, void *data)
static void create_record(SpicePulse *pulse)
{
- SpicePulsePrivate *p = SPICE_PULSE_GET_PRIVATE(pulse);
+ SpicePulsePrivate *p = pulse->priv;
pa_buffer_attr buffer_attr = { 0, };
pa_stream_flags_t flags;
@@ -525,7 +530,7 @@ static void record_start(SpiceRecordChannel *channel, gint format, gint channels
gint frequency, gpointer data)
{
SpicePulse *pulse = data;
- SpicePulsePrivate *p = SPICE_PULSE_GET_PRIVATE(pulse);
+ SpicePulsePrivate *p = pulse->priv;
pa_context_state_t state;
p->record.started = TRUE;
@@ -793,8 +798,10 @@ static gboolean connect_channel(SpiceAudio *audio, SpiceChannel *channel)
static void context_state_callback(pa_context *c, void *userdata)
{
+ SpicePulse *pulse = userdata;
SpicePulsePrivate *p;
- p = SPICE_PULSE_GET_PRIVATE(userdata);
+
+ p = pulse->priv;
g_return_if_fail(p != NULL);
g_return_if_fail(c != NULL);
@@ -836,7 +843,7 @@ SpicePulse *spice_pulse_new(SpiceSession *session, GMainContext *context,
"session", session,
"main-context", context,
NULL);
- p = SPICE_PULSE_GET_PRIVATE(pulse);
+ p = pulse->priv;
p->mainloop = pa_glib_mainloop_new(context);
p->state = PA_CONTEXT_READY;
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index 9c7316e..49afc97 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -211,7 +211,7 @@ static void
spice_session_finalize(GObject *gobject)
{
SpiceSession *session = SPICE_SESSION(gobject);
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
/* release stuff */
g_free(s->host);
@@ -244,7 +244,7 @@ spice_session_finalize(GObject *gobject)
static int spice_uri_create(SpiceSession *session, char *dest, int len)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
int pos = 0;
if (s->host == NULL || (s->port == NULL && s->tls_port == NULL)) {
@@ -261,7 +261,7 @@ static int spice_uri_create(SpiceSession *session, char *dest, int len)
static int spice_parse_uri(SpiceSession *session, const char *original_uri)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
gchar *host = NULL, *port = NULL, *tls_port = NULL, *uri = NULL, *password = NULL;
gchar *path = NULL;
gchar *unescaped_path = NULL;
@@ -398,7 +398,7 @@ static void spice_session_get_property(GObject *gobject,
GParamSpec *pspec)
{
SpiceSession *session = SPICE_SESSION(gobject);
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
char buf[256];
int len;
@@ -506,7 +506,7 @@ static void spice_session_set_property(GObject *gobject,
GParamSpec *pspec)
{
SpiceSession *session = SPICE_SESSION(gobject);
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
const char *str;
switch (prop_id) {
@@ -1259,9 +1259,12 @@ SpiceSession *spice_session_new_from_session(SpiceSession *session)
**/
gboolean spice_session_connect(SpiceSession *session)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s;
- g_return_val_if_fail(s != NULL, FALSE);
+ g_return_val_if_fail(SPICE_IS_SESSION(session), FALSE);
+ g_return_val_if_fail(session->priv != NULL, FALSE);
+
+ s = session->priv;
spice_session_disconnect(session);
s->disconnecting = FALSE;
@@ -1291,11 +1294,14 @@ gboolean spice_session_connect(SpiceSession *session)
**/
gboolean spice_session_open_fd(SpiceSession *session, int fd)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s;
- g_return_val_if_fail(s != NULL, FALSE);
+ g_return_val_if_fail(SPICE_IS_SESSION(session), FALSE);
+ g_return_val_if_fail(session->priv != NULL, FALSE);
g_return_val_if_fail(fd >= -1, FALSE);
+ s = session->priv;
+
spice_session_disconnect(session);
s->disconnecting = FALSE;
@@ -1311,7 +1317,7 @@ gboolean spice_session_open_fd(SpiceSession *session, int fd)
G_GNUC_INTERNAL
gboolean spice_session_get_client_provided_socket(SpiceSession *session)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
g_return_val_if_fail(s != NULL, FALSE);
return s->client_provided_sockets;
@@ -1319,7 +1325,7 @@ gboolean spice_session_get_client_provided_socket(SpiceSession *session)
static void cache_clear_all(SpiceSession *self)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(self);
+ SpiceSessionPrivate *s = self->priv;
cache_clear(s->images);
glz_decoder_window_clear(s->glz_window);
@@ -1328,7 +1334,7 @@ static void cache_clear_all(SpiceSession *self)
G_GNUC_INTERNAL
void spice_session_switching_disconnect(SpiceSession *self)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(self);
+ SpiceSessionPrivate *s = self->priv;
struct channel *item;
RingItem *ring, *next;
@@ -1354,8 +1360,8 @@ void spice_session_set_migration(SpiceSession *session,
SpiceSession *migration,
gboolean full_migration)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
- SpiceSessionPrivate *m = SPICE_SESSION_GET_PRIVATE(migration);
+ SpiceSessionPrivate *s = session->priv;
+ SpiceSessionPrivate *m = migration->priv;
gchar *tmp;
g_return_if_fail(s != NULL);
@@ -1415,7 +1421,7 @@ SpiceChannel* spice_session_lookup_channel(SpiceSession *session, gint id, gint
G_GNUC_INTERNAL
void spice_session_abort_migration(SpiceSession *session)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
RingItem *ring, *next;
struct channel *c;
@@ -1453,7 +1459,7 @@ void spice_session_abort_migration(SpiceSession *session)
G_GNUC_INTERNAL
void spice_session_channel_migrate(SpiceSession *session, SpiceChannel *channel)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
SpiceChannel *c;
gint id, type;
@@ -1583,11 +1589,14 @@ gboolean spice_session_get_read_only(SpiceSession *self)
**/
void spice_session_disconnect(SpiceSession *session)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s;
struct channel *item;
RingItem *ring, *next;
- g_return_if_fail(s != NULL);
+ g_return_if_fail(SPICE_IS_SESSION(session));
+ g_return_if_fail(session->priv != NULL);
+
+ s = session->priv;
SPICE_DEBUG("session: disconnecting %d", s->disconnecting);
if (s->disconnecting)
@@ -1624,12 +1633,15 @@ void spice_session_disconnect(SpiceSession *session)
**/
GList *spice_session_get_channels(SpiceSession *session)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s;
struct channel *item;
GList *list = NULL;
RingItem *ring;
- g_return_val_if_fail(s != NULL, NULL);
+ g_return_val_if_fail(SPICE_IS_SESSION(session), NULL);
+ g_return_val_if_fail(session->priv != NULL, NULL);
+
+ s = session->priv;
for (ring = ring_get_head(&s->channels);
ring != NULL;
@@ -1651,11 +1663,14 @@ GList *spice_session_get_channels(SpiceSession *session)
**/
gboolean spice_session_has_channel_type(SpiceSession *session, gint type)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s;
struct channel *item;
RingItem *ring;
- g_return_val_if_fail(s != NULL, FALSE);
+ g_return_val_if_fail(SPICE_IS_SESSION(session), FALSE);
+ g_return_val_if_fail(session->priv != NULL, FALSE);
+
+ s = session->priv;
for (ring = ring_get_head(&s->channels);
ring != NULL;
@@ -1722,7 +1737,8 @@ static void proxy_lookup_ready(GObject *source_object, GAsyncResult *result,
gpointer data)
{
spice_open_host *open_host = data;
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(open_host->session);
+ SpiceSession *session = open_host->session;
+ SpiceSessionPrivate *s = session->priv;
GList *addresses = NULL, *it;
GSocketAddress *address;
@@ -1755,7 +1771,8 @@ static void proxy_lookup_ready(GObject *source_object, GAsyncResult *result,
static gboolean open_host_idle_cb(gpointer data)
{
spice_open_host *open_host = data;
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(open_host->session);
+ SpiceSession *session = open_host->session;
+ SpiceSessionPrivate *s = session->priv;
g_return_val_if_fail(open_host != NULL, FALSE);
g_return_val_if_fail(open_host->connection == NULL, FALSE);
@@ -1811,7 +1828,7 @@ G_GNUC_INTERNAL
GSocketConnection* spice_session_channel_open_host(SpiceSession *session, SpiceChannel *channel,
gboolean *use_tls, GError **error)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
SpiceChannelPrivate *c = channel->priv;
spice_open_host open_host = { 0, };
gchar *port, *endptr;
@@ -1878,7 +1895,7 @@ GSocketConnection* spice_session_channel_open_host(SpiceSession *session, SpiceC
G_GNUC_INTERNAL
void spice_session_channel_new(SpiceSession *session, SpiceChannel *channel)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
struct channel *item;
g_return_if_fail(s != NULL);
@@ -1912,7 +1929,7 @@ void spice_session_channel_new(SpiceSession *session, SpiceChannel *channel)
G_GNUC_INTERNAL
void spice_session_channel_destroy(SpiceSession *session, SpiceChannel *channel)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
struct channel *item = NULL;
RingItem *ring;
@@ -1945,7 +1962,7 @@ void spice_session_channel_destroy(SpiceSession *session, SpiceChannel *channel)
G_GNUC_INTERNAL
void spice_session_set_connection_id(SpiceSession *session, int id)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
g_return_if_fail(s != NULL);
@@ -1955,7 +1972,7 @@ void spice_session_set_connection_id(SpiceSession *session, int id)
G_GNUC_INTERNAL
int spice_session_get_connection_id(SpiceSession *session)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
g_return_val_if_fail(s != NULL, -1);
@@ -1965,7 +1982,7 @@ int spice_session_get_connection_id(SpiceSession *session)
G_GNUC_INTERNAL
guint32 spice_session_get_mm_time(SpiceSession *session)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
g_return_val_if_fail(s != NULL, 0);
@@ -1979,7 +1996,7 @@ guint32 spice_session_get_mm_time(SpiceSession *session)
G_GNUC_INTERNAL
void spice_session_set_mm_time(SpiceSession *session, guint32 time)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
guint32 old_time;
g_return_if_fail(s != NULL);
@@ -2013,7 +2030,7 @@ void spice_session_set_port(SpiceSession *session, int port, gboolean tls)
G_GNUC_INTERNAL
void spice_session_get_pubkey(SpiceSession *session, guint8 **pubkey, guint *size)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
g_return_if_fail(s != NULL);
g_return_if_fail(pubkey != NULL);
@@ -2026,7 +2043,7 @@ void spice_session_get_pubkey(SpiceSession *session, guint8 **pubkey, guint *siz
G_GNUC_INTERNAL
void spice_session_get_ca(SpiceSession *session, guint8 **ca, guint *size)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
g_return_if_fail(s != NULL);
g_return_if_fail(ca != NULL);
@@ -2039,7 +2056,7 @@ void spice_session_get_ca(SpiceSession *session, guint8 **ca, guint *size)
G_GNUC_INTERNAL
guint spice_session_get_verify(SpiceSession *session)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
g_return_val_if_fail(s != NULL, 0);
return s->verify;
@@ -2048,7 +2065,7 @@ guint spice_session_get_verify(SpiceSession *session)
G_GNUC_INTERNAL
void spice_session_set_migration_state(SpiceSession *session, SpiceSessionMigration state)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
g_return_if_fail(s != NULL);
s->migration_state = state;
@@ -2058,7 +2075,7 @@ void spice_session_set_migration_state(SpiceSession *session, SpiceSessionMigrat
G_GNUC_INTERNAL
const gchar* spice_session_get_password(SpiceSession *session)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
g_return_val_if_fail(s != NULL, NULL);
return s->password;
@@ -2067,7 +2084,7 @@ const gchar* spice_session_get_password(SpiceSession *session)
G_GNUC_INTERNAL
const gchar* spice_session_get_host(SpiceSession *session)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
g_return_val_if_fail(s != NULL, NULL);
return s->host;
@@ -2076,7 +2093,7 @@ const gchar* spice_session_get_host(SpiceSession *session)
G_GNUC_INTERNAL
const gchar* spice_session_get_cert_subject(SpiceSession *session)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
g_return_val_if_fail(s != NULL, NULL);
return s->cert_subject;
@@ -2085,7 +2102,7 @@ const gchar* spice_session_get_cert_subject(SpiceSession *session)
G_GNUC_INTERNAL
const gchar* spice_session_get_ciphers(SpiceSession *session)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
g_return_val_if_fail(s != NULL, NULL);
return s->ciphers;
@@ -2094,7 +2111,7 @@ const gchar* spice_session_get_ciphers(SpiceSession *session)
G_GNUC_INTERNAL
const gchar* spice_session_get_ca_file(SpiceSession *session)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
g_return_val_if_fail(s != NULL, NULL);
return s->ca_file;
@@ -2105,7 +2122,7 @@ void spice_session_get_caches(SpiceSession *session,
display_cache **images,
SpiceGlzDecoderWindow **glz_window)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
g_return_if_fail(s != NULL);
@@ -2120,7 +2137,7 @@ void spice_session_set_caches_hints(SpiceSession *session,
uint32_t pci_ram_size,
uint32_t display_channels_count)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
g_return_if_fail(s != NULL);
@@ -2142,7 +2159,7 @@ void spice_session_set_caches_hints(SpiceSession *session,
G_GNUC_INTERNAL
void spice_session_set_uuid(SpiceSession *session, guint8 uuid[16])
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
g_return_if_fail(s != NULL);
memcpy(s->uuid, uuid, sizeof(s->uuid));
@@ -2153,7 +2170,7 @@ void spice_session_set_uuid(SpiceSession *session, guint8 uuid[16])
G_GNUC_INTERNAL
void spice_session_set_name(SpiceSession *session, const gchar *name)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
g_return_if_fail(s != NULL);
g_free(s->name);
@@ -2165,7 +2182,7 @@ void spice_session_set_name(SpiceSession *session, const gchar *name)
G_GNUC_INTERNAL
void spice_session_sync_playback_latency(SpiceSession *session)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
g_return_if_fail(s != NULL);
@@ -2180,7 +2197,7 @@ void spice_session_sync_playback_latency(SpiceSession *session)
G_GNUC_INTERNAL
gboolean spice_session_is_playback_active(SpiceSession *session)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
g_return_val_if_fail(s != NULL, FALSE);
@@ -2191,7 +2208,7 @@ gboolean spice_session_is_playback_active(SpiceSession *session)
G_GNUC_INTERNAL
guint32 spice_session_get_playback_latency(SpiceSession *session)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
g_return_val_if_fail(s != NULL, 0);
@@ -2207,7 +2224,7 @@ guint32 spice_session_get_playback_latency(SpiceSession *session)
G_GNUC_INTERNAL
const gchar* spice_session_get_shared_dir(SpiceSession *session)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
g_return_val_if_fail(s != NULL, NULL);
@@ -2217,7 +2234,7 @@ const gchar* spice_session_get_shared_dir(SpiceSession *session)
G_GNUC_INTERNAL
void spice_session_set_shared_dir(SpiceSession *session, const gchar *dir)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s = session->priv;
g_return_if_fail(dir != NULL);
g_return_if_fail(s != NULL);
@@ -2235,7 +2252,12 @@ void spice_session_set_shared_dir(SpiceSession *session, const gchar *dir)
**/
SpiceURI *spice_session_get_proxy_uri(SpiceSession *session)
{
- SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
+ SpiceSessionPrivate *s;
+
+ g_return_val_if_fail(SPICE_IS_SESSION(session), NULL);
+ g_return_val_if_fail(session->priv != NULL, NULL);
+
+ s = session->priv;
return s->proxy;
}
diff --git a/gtk/spice-widget-cairo.c b/gtk/spice-widget-cairo.c
index 881cc5d..1c7b358 100644
--- a/gtk/spice-widget-cairo.c
+++ b/gtk/spice-widget-cairo.c
@@ -25,7 +25,7 @@
G_GNUC_INTERNAL
int spicex_image_create(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
if (d->ximage != NULL)
return 0;
@@ -51,7 +51,7 @@ int spicex_image_create(SpiceDisplay *display)
G_GNUC_INTERNAL
void spicex_image_destroy(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
if (d->ximage) {
cairo_surface_destroy(d->ximage);
@@ -67,7 +67,7 @@ void spicex_image_destroy(SpiceDisplay *display)
G_GNUC_INTERNAL
void spicex_draw_event(SpiceDisplay *display, cairo_t *cr)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
cairo_rectangle_int_t rect;
cairo_region_t *region;
double s;
@@ -153,6 +153,6 @@ void spicex_expose_event(SpiceDisplay *display, GdkEventExpose *expose)
G_GNUC_INTERNAL
gboolean spicex_is_scaled(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
return d->allow_scaling;
}
diff --git a/gtk/spice-widget-x11.c b/gtk/spice-widget-x11.c
index f76bf2c..3f2ce94 100644
--- a/gtk/spice-widget-x11.c
+++ b/gtk/spice-widget-x11.c
@@ -119,7 +119,7 @@ static int catch_no_mitshm(Display * dpy, XErrorEvent * event)
G_GNUC_INTERNAL
int spicex_image_create(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
if (d->ximage != NULL)
return 0;
@@ -189,7 +189,7 @@ int spicex_image_create(SpiceDisplay *display)
G_GNUC_INTERNAL
void spicex_image_destroy(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
if (d->ximage) {
/* avoid XDestroy to free shared memory, owned and freed by
@@ -220,7 +220,7 @@ G_GNUC_INTERNAL
void spicex_expose_event(SpiceDisplay *display, GdkEventExpose *expose)
{
GdkDrawable *window = gtk_widget_get_window(GTK_WIDGET(display));
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
int x, y, w, h;
spice_display_get_scaling(display, NULL, &x, &y, &w, &h);
diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index 154c43e..b6bb0a9 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -124,7 +124,7 @@ static void spice_display_get_property(GObject *object,
GParamSpec *pspec)
{
SpiceDisplay *display = SPICE_DISPLAY(object);
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
gboolean boolean;
switch (prop_id) {
@@ -176,7 +176,7 @@ static void spice_display_get_property(GObject *object,
static void scaling_updated(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(display));
recalc_geometry(GTK_WIDGET(display));
@@ -187,7 +187,7 @@ static void scaling_updated(SpiceDisplay *display)
static void update_size_request(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
gint reqwidth, reqheight;
if (d->resize_guest_enable) {
@@ -204,7 +204,7 @@ static void update_size_request(SpiceDisplay *display)
static void update_keyboard_focus(SpiceDisplay *display, gboolean state)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
d->keyboard_have_focus = state;
@@ -220,7 +220,7 @@ static void update_keyboard_focus(SpiceDisplay *display, gboolean state)
static void update_ready(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
gboolean ready;
ready = d->mark != 0 && d->monitor_ready;
@@ -245,7 +245,7 @@ static void set_monitor_ready(SpiceDisplay *self, gboolean ready)
static gint get_display_id(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
/* supported monitor_id only with display channel #0 */
if (d->channel_id == 0 && d->monitor_id >= 0)
@@ -258,7 +258,7 @@ static gint get_display_id(SpiceDisplay *display)
static void update_monitor_area(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
SpiceDisplayMonitorConfig *cfg, *c = NULL;
GArray *monitors = NULL;
int i;
@@ -313,7 +313,7 @@ static void spice_display_set_property(GObject *object,
GParamSpec *pspec)
{
SpiceDisplay *display = SPICE_DISPLAY(object);
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
switch (prop_id) {
case PROP_SESSION:
@@ -386,7 +386,7 @@ static void session_inhibit_keyboard_grab_changed(GObject *gobject,
gpointer user_data)
{
SpiceDisplay *display = user_data;
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
g_object_get(d->session, "inhibit-keyboard-grab",
&d->keyboard_grab_inhibit, NULL);
@@ -397,7 +397,7 @@ static void session_inhibit_keyboard_grab_changed(GObject *gobject,
static void spice_display_dispose(GObject *obj)
{
SpiceDisplay *display = SPICE_DISPLAY(obj);
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
SPICE_DEBUG("spice display dispose");
@@ -416,7 +416,7 @@ static void spice_display_dispose(GObject *obj)
static void spice_display_finalize(GObject *obj)
{
SpiceDisplay *display = SPICE_DISPLAY(obj);
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
SPICE_DEBUG("Finalize spice display");
@@ -484,7 +484,7 @@ static void drag_data_received_callback(SpiceDisplay *self,
const guchar *buf;
gchar **file_urls;
int n_files;
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(self);
+ SpiceDisplayPrivate *d = self->priv;
int i = 0;
GFile **files;
@@ -579,7 +579,7 @@ spice_display_constructor(GType gtype,
}
display = SPICE_DISPLAY(obj);
- d = SPICE_DISPLAY_GET_PRIVATE(display);
+ d = display->priv;
if (!d->session)
g_error("SpiceDisplay constructed without a session");
@@ -697,7 +697,7 @@ SpiceGrabSequence *spice_display_get_grab_keys(SpiceDisplay *display)
static void try_keyboard_grab(SpiceDisplay *display)
{
GtkWidget *widget = GTK_WIDGET(display);
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
GdkGrabStatus status;
if (g_getenv("SPICE_NOGRAB"))
@@ -740,7 +740,7 @@ static void try_keyboard_grab(SpiceDisplay *display)
static void try_keyboard_ungrab(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
GtkWidget *widget = GTK_WIDGET(display);
if (!d->keyboard_grab_active)
@@ -760,7 +760,7 @@ static void try_keyboard_ungrab(SpiceDisplay *display)
static void update_keyboard_grab(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
if (d->keyboard_grab_enable &&
!d->keyboard_grab_inhibit &&
@@ -772,7 +772,7 @@ static void update_keyboard_grab(SpiceDisplay *display)
static void set_mouse_accel(SpiceDisplay *display, gboolean enabled)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
#if defined GDK_WINDOWING_X11
GdkWindow *w = GDK_WINDOW(gtk_widget_get_window(GTK_WIDGET(display)));
@@ -857,7 +857,7 @@ error:
static GdkGrabStatus do_pointer_grab(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
GdkWindow *window = GDK_WINDOW(gtk_widget_get_window(GTK_WIDGET(display)));
GdkGrabStatus status = GDK_GRAB_BROKEN;
GdkCursor *blank = get_blank_cursor();
@@ -907,7 +907,7 @@ end:
static void update_mouse_pointer(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
GdkWindow *window = GDK_WINDOW(gtk_widget_get_window(GTK_WIDGET(display)));
if (!window)
@@ -930,7 +930,7 @@ static void update_mouse_pointer(SpiceDisplay *display)
static void try_mouse_grab(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
if (g_getenv("SPICE_NOGRAB"))
return;
@@ -958,7 +958,7 @@ static void try_mouse_grab(SpiceDisplay *display)
static void mouse_wrap(SpiceDisplay *display, GdkEventMotion *motion)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
gint xr, yr;
#ifdef WIN32
@@ -990,7 +990,7 @@ static void mouse_wrap(SpiceDisplay *display, GdkEventMotion *motion)
static void try_mouse_ungrab(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
if (!d->mouse_grab_active)
return;
@@ -1009,7 +1009,7 @@ static void try_mouse_ungrab(SpiceDisplay *display)
static void update_mouse_grab(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
if (d->mouse_grab_enable &&
!d->keyboard_grab_inhibit &&
@@ -1022,7 +1022,7 @@ static void update_mouse_grab(SpiceDisplay *display)
static void recalc_geometry(GtkWidget *widget)
{
SpiceDisplay *display = SPICE_DISPLAY(widget);
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
gdouble zoom = 1.0;
if (spicex_is_scaled(display))
@@ -1055,7 +1055,7 @@ static void recalc_geometry(GtkWidget *widget)
static gboolean do_color_convert(SpiceDisplay *display, GdkRectangle *r)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
guint32 *dest = d->data;
guint16 *src = d->data_origin;
gint x, y;
@@ -1095,7 +1095,7 @@ static gboolean do_color_convert(SpiceDisplay *display, GdkRectangle *r)
static gboolean draw_event(GtkWidget *widget, cairo_t *cr)
{
SpiceDisplay *display = SPICE_DISPLAY(widget);
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
g_return_val_if_fail(d != NULL, false);
if (d->mark == 0 || d->data == NULL ||
@@ -1112,7 +1112,7 @@ static gboolean draw_event(GtkWidget *widget, cairo_t *cr)
static gboolean expose_event(GtkWidget *widget, GdkEventExpose *expose)
{
SpiceDisplay *display = SPICE_DISPLAY(widget);
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
g_return_val_if_fail(d != NULL, false);
if (d->mark == 0 || d->data == NULL ||
@@ -1135,7 +1135,7 @@ typedef enum {
static void key_press_and_release(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
if (d->key_delayed_scancode == 0)
return;
@@ -1151,7 +1151,8 @@ static void key_press_and_release(SpiceDisplay *display)
static gboolean key_press_delayed(gpointer data)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(data);
+ SpiceDisplay *display = data;
+ SpiceDisplayPrivate *d = display->priv;
if (d->key_delayed_scancode == 0)
return FALSE;
@@ -1169,7 +1170,7 @@ static gboolean key_press_delayed(gpointer data)
static void send_key(SpiceDisplay *display, int scancode, SendKeyType type, gboolean press_delayed)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
uint32_t i, b, m;
g_return_if_fail(scancode != 0);
@@ -1224,7 +1225,7 @@ static void send_key(SpiceDisplay *display, int scancode, SendKeyType type, gboo
static void release_keys(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
uint32_t i, b;
SPICE_DEBUG("%s", __FUNCTION__);
@@ -1243,7 +1244,7 @@ static void release_keys(SpiceDisplay *display)
static gboolean check_for_grab_key(SpiceDisplay *display, int type, int keyval)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
int i;
if (!d->grabseq->nkeysyms)
@@ -1283,7 +1284,7 @@ static void update_display(SpiceDisplay *display)
static gboolean key_event(GtkWidget *widget, GdkEventKey *key)
{
SpiceDisplay *display = SPICE_DISPLAY(widget);
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
int scancode;
#ifdef WIN32
@@ -1342,7 +1343,7 @@ static gboolean key_event(GtkWidget *widget, GdkEventKey *key)
static guint get_scancode_from_keyval(SpiceDisplay *display, guint keyval)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
guint keycode = 0;
GdkKeymapKey *keys = NULL;
gint n_keys = 0;
@@ -1395,7 +1396,7 @@ void spice_display_send_keys(SpiceDisplay *display, const guint *keyvals,
static gboolean enter_event(GtkWidget *widget, GdkEventCrossing *crossing G_GNUC_UNUSED)
{
SpiceDisplay *display = SPICE_DISPLAY(widget);
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
SPICE_DEBUG("%s", __FUNCTION__);
@@ -1409,7 +1410,7 @@ static gboolean enter_event(GtkWidget *widget, GdkEventCrossing *crossing G_GNUC
static gboolean leave_event(GtkWidget *widget, GdkEventCrossing *crossing G_GNUC_UNUSED)
{
SpiceDisplay *display = SPICE_DISPLAY(widget);
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
SPICE_DEBUG("%s", __FUNCTION__);
@@ -1425,7 +1426,7 @@ static gboolean leave_event(GtkWidget *widget, GdkEventCrossing *crossing G_GNUC
static gboolean focus_in_event(GtkWidget *widget, GdkEventFocus *focus G_GNUC_UNUSED)
{
SpiceDisplay *display = SPICE_DISPLAY(widget);
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
SPICE_DEBUG("%s", __FUNCTION__);
@@ -1449,7 +1450,7 @@ static gboolean focus_in_event(GtkWidget *widget, GdkEventFocus *focus G_GNUC_UN
static gboolean focus_out_event(GtkWidget *widget, GdkEventFocus *focus G_GNUC_UNUSED)
{
SpiceDisplay *display = SPICE_DISPLAY(widget);
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
SPICE_DEBUG("%s", __FUNCTION__);
update_display(NULL);
@@ -1536,7 +1537,7 @@ void spicex_transform_input (SpiceDisplay *display,
static gboolean motion_event(GtkWidget *widget, GdkEventMotion *motion)
{
SpiceDisplay *display = SPICE_DISPLAY(widget);
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
int x, y;
if (!d->inputs)
@@ -1579,7 +1580,7 @@ static gboolean scroll_event(GtkWidget *widget, GdkEventScroll *scroll)
{
int button;
SpiceDisplay *display = SPICE_DISPLAY(widget);
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
SPICE_DEBUG("%s", __FUNCTION__);
@@ -1607,7 +1608,7 @@ static gboolean scroll_event(GtkWidget *widget, GdkEventScroll *scroll)
static gboolean button_event(GtkWidget *widget, GdkEventButton *button)
{
SpiceDisplay *display = SPICE_DISPLAY(widget);
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
int x, y;
SPICE_DEBUG("%s %s: button %d, state 0x%x", __FUNCTION__,
@@ -1669,7 +1670,7 @@ static gboolean button_event(GtkWidget *widget, GdkEventButton *button)
static gboolean configure_event(GtkWidget *widget, GdkEventConfigure *conf)
{
SpiceDisplay *display = SPICE_DISPLAY(widget);
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
if (conf->width == d->ww && conf->height == d->wh &&
conf->x == d->mx && conf->y == d->my) {
@@ -1697,7 +1698,7 @@ static gboolean configure_event(GtkWidget *widget, GdkEventConfigure *conf)
static void update_image(SpiceDisplay *display)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
spicex_image_create(display);
if (d->convert)
@@ -2017,7 +2018,7 @@ static void spice_display_class_init(SpiceDisplayClass *klass)
static void update_mouse_mode(SpiceChannel *channel, gpointer data)
{
SpiceDisplay *display = data;
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(display));
g_object_get(channel, "mouse-mode", &d->mouse_mode, NULL);
@@ -2049,7 +2050,7 @@ static void update_mouse_mode(SpiceChannel *channel, gpointer data)
static void update_area(SpiceDisplay *display,
gint x, gint y, gint width, gint height)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
GdkRectangle primary = {
.x = 0,
.y = 0,
@@ -2087,7 +2088,7 @@ static void primary_create(SpiceChannel *channel, gint format,
gint shmid, gpointer imgdata, gpointer data)
{
SpiceDisplay *display = data;
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
d->format = format;
d->stride = stride;
@@ -2102,7 +2103,7 @@ static void primary_create(SpiceChannel *channel, gint format,
static void primary_destroy(SpiceChannel *channel, gpointer data)
{
SpiceDisplay *display = SPICE_DISPLAY(data);
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
spicex_image_destroy(display);
d->width = 0;
@@ -2118,7 +2119,7 @@ static void invalidate(SpiceChannel *channel,
gint x, gint y, gint w, gint h, gpointer data)
{
SpiceDisplay *display = data;
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
int display_x, display_y;
int x1, y1, x2, y2;
double s;
@@ -2154,7 +2155,7 @@ static void invalidate(SpiceChannel *channel,
static void mark(SpiceDisplay *display, gint mark)
{
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
g_return_if_fail(d != NULL);
SPICE_DEBUG("widget mark: %d, %d:%d %p", mark, d->channel_id, d->monitor_id, display);
@@ -2167,7 +2168,7 @@ static void cursor_set(SpiceCursorChannel *channel,
gpointer rgba, gpointer data)
{
SpiceDisplay *display = data;
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
GdkCursor *cursor = NULL;
cursor_invalidate(display);
@@ -2213,7 +2214,7 @@ static void cursor_set(SpiceCursorChannel *channel,
static void cursor_hide(SpiceCursorChannel *channel, gpointer data)
{
SpiceDisplay *display = data;
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
if (d->show_cursor != NULL) /* then we are already hidden */
return;
@@ -2336,7 +2337,7 @@ static void cursor_reset(SpiceCursorChannel *channel, gpointer data)
static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer data)
{
SpiceDisplay *display = data;
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
int id;
g_object_get(channel, "channel-id", &id, NULL);
@@ -2409,7 +2410,7 @@ static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer data)
static void channel_destroy(SpiceSession *s, SpiceChannel *channel, gpointer data)
{
SpiceDisplay *display = data;
- SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+ SpiceDisplayPrivate *d = display->priv;
int id;
g_object_get(channel, "channel-id", &id, NULL);
commit b9acafcdbac449a3ec5d83b5174e73df4241482c
Author: Fabiano Fidêncio <fidencio at redhat.com>
Date: Fri Jul 11 17:13:09 2014 +0200
Prefer using g_malloc0()/g_free()
As we already depend on GLib, let's use g_{malloc,new}0() instead of the
standard malloc() or the spice_{malloc,new}*() and g_free() instead of
the standard free() when possible.
Memory allocated by other libraries using malloc() should still be freed
by free().
As a side effect of the changes, we are muting a few warnings caught by
coverity.
diff --git a/gtk/channel-cursor.c b/gtk/channel-cursor.c
index a7d7153..ae788dc 100644
--- a/gtk/channel-cursor.c
+++ b/gtk/channel-cursor.c
@@ -323,7 +323,7 @@ static display_cursor *set_cursor(SpiceChannel *channel, SpiceCursor *scursor)
g_return_val_if_fail(scursor->data_size != 0, NULL);
size = 4u * hdr->width * hdr->height;
- cursor = spice_malloc(sizeof(*cursor) + size);
+ cursor = g_malloc0(sizeof(*cursor) + size);
cursor->hdr = *hdr;
cursor->default_cursor = FALSE;
cursor->refcount = 1;
diff --git a/gtk/channel-display-mjpeg.c b/gtk/channel-display-mjpeg.c
index 2ad653e..95d5b33 100644
--- a/gtk/channel-display-mjpeg.c
+++ b/gtk/channel-display-mjpeg.c
@@ -73,11 +73,9 @@ void stream_mjpeg_data(display_stream *st)
uint8_t *lines[4];
stream_get_dimensions(st, &width, &height);
- dest = malloc(width * height * 4);
+ dest = g_malloc0(width * height * 4);
- if (st->out_frame) {
- free(st->out_frame);
- }
+ g_free(st->out_frame);
st->out_frame = dest;
jpeg_read_header(&st->mjpeg_cinfo, 1);
@@ -153,6 +151,6 @@ G_GNUC_INTERNAL
void stream_mjpeg_cleanup(display_stream *st)
{
jpeg_destroy_decompress(&st->mjpeg_cinfo);
- free(st->out_frame);
+ g_free(st->out_frame);
st->out_frame = NULL;
}
diff --git a/gtk/channel-display.c b/gtk/channel-display.c
index 6265334..6fa97aa 100644
--- a/gtk/channel-display.c
+++ b/gtk/channel-display.c
@@ -730,7 +730,7 @@ static void destroy_canvas(display_surface *surface)
jpeg_decoder_destroy(surface->jpeg_decoder);
if (surface->shmid == -1) {
- free(surface->data);
+ g_free(surface->data);
}
#ifdef HAVE_SYS_SHM_H
else {
@@ -986,7 +986,7 @@ static void display_handle_stream_create(SpiceChannel *channel, SpiceMsgIn *in)
memset(c->streams + n, 0, (c->nstreams - n) * sizeof(c->streams[0]));
}
g_return_if_fail(c->streams[op->id] == NULL);
- c->streams[op->id] = spice_new0(display_stream, 1);
+ c->streams[op->id] = g_new0(display_stream, 1);
st = c->streams[op->id];
st->msg_create = in;
@@ -1486,7 +1486,7 @@ static void destroy_stream(SpiceChannel *channel, int id)
g_queue_free(st->msgq);
if (st->timeout != 0)
g_source_remove(st->timeout);
- free(st);
+ g_free(st);
c->streams[id] = NULL;
}
@@ -1498,7 +1498,7 @@ static void clear_streams(SpiceChannel *channel)
for (i = 0; i < c->nstreams; i++) {
destroy_stream(channel, i);
}
- free(c->streams);
+ g_free(c->streams);
c->streams = NULL;
c->nstreams = 0;
}
diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index 352499c..7a299a4 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -1050,7 +1050,7 @@ gboolean spice_main_send_monitor_config(SpiceMainChannel *channel)
}
size = sizeof(VDAgentMonitorsConfig) + sizeof(VDAgentMonConfig) * monitors;
- mon = spice_malloc0(size);
+ mon = g_malloc0(size);
mon->num_of_monitors = monitors;
if (c->disable_display_position == FALSE ||
@@ -1081,7 +1081,7 @@ gboolean spice_main_send_monitor_config(SpiceMainChannel *channel)
monitors_align(mon->monitors, mon->num_of_monitors);
agent_msg_queue(channel, VD_AGENT_MONITORS_CONFIG, size, mon);
- free(mon);
+ g_free(mon);
spice_channel_wakeup(SPICE_CHANNEL(channel), FALSE);
if (c->timer_id != 0) {
@@ -1133,7 +1133,7 @@ static void agent_announce_caps(SpiceMainChannel *channel)
return;
size = sizeof(VDAgentAnnounceCapabilities) + VD_AGENT_CAPS_BYTES;
- caps = spice_malloc0(size);
+ caps = g_malloc0(size);
if (!c->agent_caps_received)
caps->request = 1;
VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_MOUSE_STATE);
@@ -1144,7 +1144,7 @@ static void agent_announce_caps(SpiceMainChannel *channel)
VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_CLIPBOARD_SELECTION);
agent_msg_queue(channel, VD_AGENT_ANNOUNCE_CAPABILITIES, size, caps);
- free(caps);
+ g_free(caps);
}
/* any context: the message is not flushed immediately,
@@ -1879,7 +1879,7 @@ static void main_handle_agent_data_msg(SpiceChannel* channel, int* msg_size, guc
SPICE_DEBUG("agent msg start: msg_size=%d, protocol=%d, type=%d",
c->agent_msg.size, c->agent_msg.protocol, c->agent_msg.type);
g_return_if_fail(c->agent_msg_data == NULL);
- c->agent_msg_data = g_malloc(c->agent_msg.size);
+ c->agent_msg_data = g_malloc0(c->agent_msg.size);
}
}
@@ -2740,7 +2740,7 @@ static void file_xfer_send_start_msg_async(SpiceMainChannel *channel,
SpiceFileXferTask *task;
static uint32_t xfer_id; /* Used to identify task id */
- task = spice_malloc0(sizeof(SpiceFileXferTask));
+ task = g_malloc0(sizeof(SpiceFileXferTask));
task->id = ++xfer_id;
task->channel = g_object_ref(channel);
task->file = g_object_ref(file);
diff --git a/gtk/channel-record.c b/gtk/channel-record.c
index 20af3de..946d66f 100644
--- a/gtk/channel-record.c
+++ b/gtk/channel-record.c
@@ -418,7 +418,7 @@ static void record_handle_start(SpiceChannel *channel, SpiceMsgIn *in)
g_free(c->last_frame);
c->frame_bytes = frame_size * 16 * start->channels / 8;
- c->last_frame = g_malloc(c->frame_bytes);
+ c->last_frame = g_malloc0(c->frame_bytes);
c->last_frame_current = 0;
g_coroutine_signal_emit(channel, signals[SPICE_RECORD_START], 0,
diff --git a/gtk/channel-webdav.c b/gtk/channel-webdav.c
index b8b0993..0529b59 100644
--- a/gtk/channel-webdav.c
+++ b/gtk/channel-webdav.c
@@ -388,7 +388,7 @@ static void client_connected(GObject *source_object,
client->self = self;
client->conn = conn;
client->mux.id = GINT64_TO_LE(client->id);
- client->mux.buf = g_malloc(MAX_MUX_SIZE);
+ client->mux.buf = g_malloc0(MAX_MUX_SIZE);
client->cancellable = g_cancellable_new();
output = g_buffered_output_stream_new(g_io_stream_get_output_stream(G_IO_STREAM(conn)));
@@ -559,7 +559,7 @@ static void spice_webdav_channel_init(SpiceWebdavChannel *channel)
c->cancellable = g_cancellable_new();
c->clients = g_hash_table_new_full(g_int64_hash, g_int64_equal,
NULL, client_remove_unref);
- c->demux.buf = g_malloc(MAX_MUX_SIZE);
+ c->demux.buf = g_malloc0(MAX_MUX_SIZE);
GOutputStream *ostream = g_io_stream_get_output_stream(G_IO_STREAM(c->stream));
c->queue = output_queue_new(ostream);
diff --git a/gtk/controller/test.c b/gtk/controller/test.c
index 851f237..f426669 100644
--- a/gtk/controller/test.c
+++ b/gtk/controller/test.c
@@ -94,13 +94,13 @@ void send_value (uint32_t id, uint32_t value)
void send_data (uint32_t id, uint8_t* data, size_t data_size)
{
size_t size = sizeof (ControllerData) + data_size;
- ControllerData* msg = (ControllerData*)malloc (size);
+ ControllerData* msg = (ControllerData*)g_malloc0 (size);
msg->base.id = id;
msg->base.size = (uint32_t)size;
memcpy (msg->data, data, data_size);
write_to_pipe (msg, size);
- free (msg);
+ g_free (msg);
}
ssize_t read_from_pipe (void* data, size_t size)
diff --git a/gtk/decode-glz.c b/gtk/decode-glz.c
index b09de00..34a7185 100644
--- a/gtk/decode-glz.c
+++ b/gtk/decode-glz.c
@@ -52,7 +52,7 @@ static struct glz_image *glz_image_new(struct glz_image_hdr *hdr,
g_return_val_if_fail(type == LZ_IMAGE_TYPE_RGB32 || type == LZ_IMAGE_TYPE_RGBA, NULL);
- img = spice_new0(struct glz_image, 1);
+ img = g_new0(struct glz_image, 1);
img->hdr = *hdr;
img->surface = alloc_lz_image_surface
(opaque, type == LZ_IMAGE_TYPE_RGBA ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8,
@@ -94,7 +94,7 @@ static void glz_decoder_window_resize(SpiceGlzDecoderWindow *w)
SPICE_DEBUG("%s: array resize %d -> %d", __FUNCTION__,
w->nimages, w->nimages * 2);
- new_images = spice_new0(struct glz_image*, w->nimages * 2);
+ new_images = g_new0(struct glz_image*, w->nimages * 2);
for (i = 0; i < w->nimages; i++) {
if (w->images[i] == NULL) {
/*
@@ -440,13 +440,13 @@ void glz_decoder_window_clear(SpiceGlzDecoderWindow *w)
w->nimages = 16;
g_free(w->images);
- w->images = spice_new0(struct glz_image*, w->nimages);
+ w->images = g_new0(struct glz_image*, w->nimages);
w->tail_gap = 0;
}
SpiceGlzDecoderWindow *glz_decoder_window_new(void)
{
- SpiceGlzDecoderWindow *w = spice_new0(SpiceGlzDecoderWindow, 1);
+ SpiceGlzDecoderWindow *w = g_new0(SpiceGlzDecoderWindow, 1);
glz_decoder_window_clear(w);
return w;
}
@@ -463,7 +463,7 @@ void glz_decoder_window_destroy(SpiceGlzDecoderWindow *w)
SpiceGlzDecoder *glz_decoder_new(SpiceGlzDecoderWindow *w)
{
- GlibGlzDecoder *d = spice_new0(GlibGlzDecoder, 1);
+ GlibGlzDecoder *d = g_new0(GlibGlzDecoder, 1);
d->base.ops = &glz_decoder_ops;
d->window = w;
return &d->base;
diff --git a/gtk/decode-jpeg.c b/gtk/decode-jpeg.c
index cce7b53..db54a31 100644
--- a/gtk/decode-jpeg.c
+++ b/gtk/decode-jpeg.c
@@ -165,7 +165,7 @@ static void jpeg_decoder_term_source (j_decompress_ptr cinfo)
SpiceJpegDecoder *jpeg_decoder_new(void)
{
- GlibJpegDecoder *d = spice_new0(GlibJpegDecoder, 1);
+ GlibJpegDecoder *d = g_new0(GlibJpegDecoder, 1);
d->_cinfo.err = jpeg_std_error(&d->_jerr);
jpeg_create_decompress(&d->_cinfo);
diff --git a/gtk/decode-zlib.c b/gtk/decode-zlib.c
index 966fc16..a5325c0 100644
--- a/gtk/decode-zlib.c
+++ b/gtk/decode-zlib.c
@@ -57,7 +57,7 @@ static SpiceZlibDecoderOps zlib_decoder_ops = {
SpiceZlibDecoder *zlib_decoder_new(void)
{
- GlibZlibDecoder *d = spice_new0(GlibZlibDecoder, 1);
+ GlibZlibDecoder *d = g_new0(GlibZlibDecoder, 1);
int z_ret;
d->_z_strm.zalloc = Z_NULL;
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 1a4a5bf..521f10a 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -516,7 +516,7 @@ void spice_msg_in_unref(SpiceMsgIn *in)
if (in->parent) {
spice_msg_in_unref(in->parent);
} else {
- free(in->data);
+ g_free(in->data);
}
g_slice_free(SpiceMsgIn, in);
}
@@ -866,7 +866,7 @@ static void spice_channel_write_msg(SpiceChannel *channel, SpiceMsgOut *out)
spice_channel_write(channel, data, len);
if (free_data)
- free(data);
+ g_free(data);
spice_msg_out_unref(out);
}
@@ -1143,7 +1143,7 @@ static void spice_channel_send_link(SpiceChannel *channel)
c->link_hdr.size += (c->link_msg.num_common_caps +
c->link_msg.num_channel_caps) * sizeof(uint32_t);
- buffer = spice_malloc(sizeof(c->link_hdr) + c->link_hdr.size);
+ buffer = g_malloc0(sizeof(c->link_hdr) + c->link_hdr.size);
p = buffer;
memcpy(p, &c->link_hdr, sizeof(c->link_hdr)); p += sizeof(c->link_hdr);
@@ -1163,7 +1163,7 @@ static void spice_channel_send_link(SpiceChannel *channel)
c->link_msg.num_common_caps,
c->link_msg.num_channel_caps);
spice_channel_write(channel, buffer, p - buffer);
- free(buffer);
+ g_free(buffer);
}
/* coroutine context */
@@ -1191,7 +1191,7 @@ static gboolean spice_channel_recv_link_hdr(SpiceChannel *channel, gboolean *swi
goto error;
}
- c->peer_msg = spice_malloc(c->peer_hdr.size);
+ c->peer_msg = g_malloc0(c->peer_hdr.size);
if (c->peer_msg == NULL) {
g_warning("invalid peer header size: %u", c->peer_hdr.size);
goto error;
@@ -1427,7 +1427,7 @@ static gboolean spice_channel_perform_auth_sasl(SpiceChannel *channel)
goto error;
}
- mechlist = g_malloc(len + 1);
+ mechlist = g_malloc0(len + 1);
spice_channel_read(channel, mechlist, len);
mechlist[len] = '\0';
if (c->has_error) {
@@ -1498,7 +1498,7 @@ restart:
/* NB, distinction of NULL vs "" is *critical* in SASL */
if (len > 0) {
- serverin = g_malloc(len);
+ serverin = g_malloc0(len);
spice_channel_read(channel, serverin, len);
serverin[len - 1] = '\0';
len--;
@@ -1580,7 +1580,7 @@ restart:
/* NB, distinction of NULL vs "" is *critical* in SASL */
if (len) {
- serverin = g_malloc(len);
+ serverin = g_malloc0(len);
spice_channel_read(channel, serverin, len);
serverin[len - 1] = '\0';
len--;
@@ -1780,7 +1780,7 @@ void spice_channel_recv_msg(SpiceChannel *channel,
/* FIXME: do not allow others to take ref on in, and use realloc here?
* this would avoid malloc/free on each message?
*/
- in->data = spice_malloc(msg_size);
+ in->data = g_malloc0(msg_size);
spice_channel_read(channel, in->data, msg_size);
if (c->has_error)
goto end;
@@ -2543,7 +2543,7 @@ static void channel_reset(SpiceChannel *channel, gboolean migrating)
c->fd = -1;
- free(c->peer_msg);
+ g_free(c->peer_msg);
c->peer_msg = NULL;
c->peer_pos = 0;
diff --git a/gtk/spice-client-gtk.override b/gtk/spice-client-gtk.override
index 31e4f9e..41aeee3 100644
--- a/gtk/spice-client-gtk.override
+++ b/gtk/spice-client-gtk.override
@@ -39,21 +39,22 @@ _wrap_spice_display_send_keys(PyGObject *self,
return NULL;
len = PyList_Size(keyList);
- keys = malloc(sizeof(guint)*len);
+ keys = g_malloc0(sizeof(guint)*len);
+
for (i = 0 ; i < len ; i++) {
PyObject *val;
char *sym;
val = PyList_GetItem(keyList, i);
sym = PyString_AsString(val);
if (!sym) {
- free(keys);
+ g_free(keys);
return NULL;
}
keys[i] = gdk_keyval_from_name(sym);
}
spice_display_send_keys(SPICE_DISPLAY(self->obj), keys, len, kind);
- free(keys);
+ g_free(keys);
Py_INCREF(Py_None);
return Py_None;
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index 7aef787..9c7316e 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -1884,7 +1884,7 @@ void spice_session_channel_new(SpiceSession *session, SpiceChannel *channel)
g_return_if_fail(s != NULL);
g_return_if_fail(channel != NULL);
- item = spice_new0(struct channel, 1);
+ item = g_new0(struct channel, 1);
item->channel = channel;
ring_add(&s->channels, &item->link);
diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index 9b835f0..154c43e 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -2559,7 +2559,7 @@ GdkPixbuf *spice_display_get_pixbuf(SpiceDisplay *display)
/* TODO: ensure d->data has been exposed? */
g_return_val_if_fail(d->data != NULL, NULL);
- data = g_malloc(d->area.width * d->area.height * 3);
+ data = g_malloc0(d->area.width * d->area.height * 3);
src = d->data;
dest = data;
diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
index 1051d10..5013b6c 100644
--- a/gtk/usb-device-manager.c
+++ b/gtk/usb-device-manager.c
@@ -1017,7 +1017,7 @@ static int spice_usb_device_manager_hotplug_cb(libusb_context *ctx,
void *user_data)
{
SpiceUsbDeviceManager *self = SPICE_USB_DEVICE_MANAGER(user_data);
- struct hotplug_idle_cb_args *args = g_malloc(sizeof(*args));
+ struct hotplug_idle_cb_args *args = g_malloc0(sizeof(*args));
args->self = g_object_ref(self);
args->device = libusb_ref_device(device);
commit d7ee9f59cd21acfa815eede9627eb29ce12694be
Author: Fabiano Fidêncio <fidencio at redhat.com>
Date: Fri Jul 11 17:02:18 2014 +0200
Fix "REVERSE_INULL" caught by coverity
diff --git a/gtk/channel-cursor.c b/gtk/channel-cursor.c
index fb19536..a7d7153 100644
--- a/gtk/channel-cursor.c
+++ b/gtk/channel-cursor.c
@@ -389,7 +389,7 @@ static display_cursor *set_cursor(SpiceChannel *channel, SpiceCursor *scursor)
}
cache_add:
- if (cursor && (scursor->flags & SPICE_CURSOR_FLAGS_CACHE_ME)) {
+ if (scursor->flags & SPICE_CURSOR_FLAGS_CACHE_ME) {
cache_add(c->cursors, hdr->unique, display_cursor_ref(cursor));
}
commit 9e81400690a9752119b66bbb078c5fd132b19208
Author: Fabiano Fidêncio <fidencio at redhat.com>
Date: Fri Jul 11 16:28:46 2014 +0200
g_type_init() is deprecated in GLib 2.36
diff --git a/gtk/controller/dump.c b/gtk/controller/dump.c
index 4fcfe58..306ff3a 100644
--- a/gtk/controller/dump.c
+++ b/gtk/controller/dump.c
@@ -90,7 +90,9 @@ void connect_signals (gpointer obj)
int main (int argc, char *argv[])
{
+#if !GLIB_CHECK_VERSION(2,36,0)
g_type_init ();
+#endif
loop = g_main_loop_new (NULL, FALSE);
if (argc > 1 && g_str_equal(argv[1], "--menu")) {
diff --git a/gtk/spice-client-glib-usb-acl-helper.c b/gtk/spice-client-glib-usb-acl-helper.c
index 3ed6cad..fe247ac 100644
--- a/gtk/spice-client-glib-usb-acl-helper.c
+++ b/gtk/spice-client-glib-usb-acl-helper.c
@@ -338,7 +338,9 @@ int main(void)
return 1;
}
+#if !GLIB_CHECK_VERSION(2,36,0)
g_type_init();
+#endif
loop = g_main_loop_new(NULL, FALSE);
diff --git a/gtk/spicy-screenshot.c b/gtk/spicy-screenshot.c
index 43664b6..b60fb42 100644
--- a/gtk/spicy-screenshot.c
+++ b/gtk/spicy-screenshot.c
@@ -178,7 +178,9 @@ int main(int argc, char *argv[])
exit(0);
}
+#if !GLIB_CHECK_VERSION(2,36,0)
g_type_init();
+#endif
mainloop = g_main_loop_new(NULL, false);
session = spice_session_new();
diff --git a/gtk/spicy-stats.c b/gtk/spicy-stats.c
index f176ead..e236223 100644
--- a/gtk/spicy-stats.c
+++ b/gtk/spicy-stats.c
@@ -110,7 +110,9 @@ int main(int argc, char *argv[])
exit(0);
}
+#if !GLIB_CHECK_VERSION(2,36,0)
g_type_init();
+#endif
mainloop = g_main_loop_new(NULL, false);
session = spice_session_new();
diff --git a/gtk/spicy.c b/gtk/spicy.c
index 038d622..57af34c 100644
--- a/gtk/spicy.c
+++ b/gtk/spicy.c
@@ -1845,7 +1845,9 @@ int main(int argc, char *argv[])
exit(0);
}
+#if !GLIB_CHECK_VERSION(2,36,0)
g_type_init();
+#endif
mainloop = g_main_loop_new(NULL, false);
conn = connection_new();
More information about the Spice-commits
mailing list