[Spice-commits] common/marshaller.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Feb 7 14:53:20 UTC 2020


 common/marshaller.c |   12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

New commits:
commit 48944f6f41cd85efb400a7571a0ad22a6dd09027
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Wed Sep 11 10:06:35 2019 +0100

    marshallers: Avoid some useless pointers in SpiceMarshallerData
    
    "buffers" and "marshallers" are always pointing to the static
    buffers inside the same structure.
    Use single array fields to avoid having initialize and have them.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Julien Rope <jrope at redhat.com>

diff --git a/common/marshaller.c b/common/marshaller.c
index a2c27b7..f9d8691 100644
--- a/common/marshaller.c
+++ b/common/marshaller.c
@@ -116,16 +116,15 @@ struct SpiceMarshaller {
 struct SpiceMarshallerData {
     size_t total_size;
     size_t base;
-    SpiceMarshaller *marshallers;
     SpiceMarshaller *last_marshaller;
 
     size_t current_buffer_position;
     MarshallerBuffer *current_buffer;
     MarshallerItem *current_buffer_item;
-    MarshallerBuffer *buffers;
 
-    SpiceMarshaller static_marshaller;
-    MarshallerBuffer static_buffer;
+    // first marshaller and buffer are statically allocated here
+    SpiceMarshaller marshallers[1];
+    MarshallerBuffer buffers[1];
 };
 
 static void spice_marshaller_init(SpiceMarshaller *m,
@@ -149,16 +148,15 @@ SpiceMarshaller *spice_marshaller_new(void)
 
     d = spice_new(SpiceMarshallerData, 1);
 
-    d->last_marshaller = d->marshallers = &d->static_marshaller;
+    d->last_marshaller = d->marshallers;
     d->total_size = 0;
     d->base = 0;
-    d->buffers = &d->static_buffer;
     d->buffers->next = NULL;
     d->current_buffer = d->buffers;
     d->current_buffer_position = 0;
     d->current_buffer_item = NULL;
 
-    m = &d->static_marshaller;
+    m = d->marshallers;
     spice_marshaller_init(m, d);
 
     return m;


More information about the Spice-commits mailing list