[Spice-devel] [PATCH spice-server] red-channel-client: Do not allocate iovec array statically in the class

Frediano Ziglio fziglio at redhat.com
Mon Jun 18 07:35:52 UTC 2018


This array is just used locally in red_channel_client_handle_outgoing
so declare it there.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/red-channel-client.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 893a764d..5d256eca 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -101,8 +101,6 @@ typedef struct RedChannelClientConnectivityMonitor {
 } RedChannelClientConnectivityMonitor;
 
 typedef struct OutgoingMessageBuffer {
-    struct iovec vec[IOV_MAX];
-    int vec_size;
     int pos;
     int size;
 } OutgoingMessageBuffer;
@@ -1081,10 +1079,11 @@ static void red_channel_client_handle_outgoing(RedChannelClient *rcc)
     }
 
     for (;;) {
-        buffer->vec_size =
-            red_channel_client_prepare_out_msg(rcc, buffer->vec, G_N_ELEMENTS(buffer->vec),
+        struct iovec vec[IOV_MAX];
+        int vec_size =
+            red_channel_client_prepare_out_msg(rcc, vec, G_N_ELEMENTS(vec),
                                                buffer->pos);
-        n = red_stream_writev(stream, buffer->vec, buffer->vec_size);
+        n = red_stream_writev(stream, vec, vec_size);
         if (n == -1) {
             switch (errno) {
             case EAGAIN:
-- 
2.17.1



More information about the Spice-devel mailing list