[Spice-devel] [PATCH 4/7] Use memcpy call in red_channel_create

Dan McGee dpmcgee at gmail.com
Thu Feb 16 21:30:10 PST 2012


Rather than assign the callbacks one-by-one, we can just memcpy the
struct into the one we have allocated in our RedChannel object, which is
much more efficient, not to mention future-proof when more callbacks are
added.

Signed-off-by: Dan McGee <dpmcgee at gmail.com>
---
 server/red_channel.c |    9 +--------
 1 files changed, 1 insertions(+), 8 deletions(-)

diff --git a/server/red_channel.c b/server/red_channel.c
index fe50d2f..767f907 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -610,14 +610,7 @@ RedChannel *red_channel_create(int size,
     channel->type = type;
     channel->id = id;
     channel->handle_acks = handle_acks;
-    channel->channel_cbs.on_disconnect = channel_cbs->on_disconnect;
-    channel->channel_cbs.send_item = channel_cbs->send_item;
-    channel->channel_cbs.release_item = channel_cbs->release_item;
-    channel->channel_cbs.hold_item = channel_cbs->hold_item;
-    channel->channel_cbs.handle_migrate_flush_mark = channel_cbs->handle_migrate_flush_mark;
-    channel->channel_cbs.handle_migrate_data = channel_cbs->handle_migrate_data;
-    channel->channel_cbs.handle_migrate_data_get_serial = channel_cbs->handle_migrate_data_get_serial;
-    channel->channel_cbs.config_socket = channel_cbs->config_socket;
+    memcpy(&channel->channel_cbs, channel_cbs, sizeof(ChannelCbs));
 
     channel->core = core;
     channel->migrate = migrate;
-- 
1.7.9.1



More information about the Spice-devel mailing list