[PATCH 25/30] Change RedGlzDrawable::drawable from pointer to boolean

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The field was used just as a flag.
This has the advantage to make clear to not use the pointer as we don't
have ownership.
Also many the structure a bit smaller.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/dcc-encoders.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c
index c49561f..97e1427 100644
--- a/server/dcc-encoders.c
+++ b/server/dcc-encoders.c
@@ -48,10 +48,10 @@ struct RedGlzDrawable {
     RingItem link;    // ordered by the time it was encoded
     RingItem drawable_link;
     RedDrawable *red_drawable;
-    struct Drawable    *drawable;
     GlzDrawableInstanceItem instances_pool[MAX_GLZ_DRAWABLE_INSTANCES];
     Ring instances;
     uint8_t instances_count;
+    gboolean has_drawable;
     EncodersData *encoders;
 };
 
@@ -502,9 +502,7 @@ static void dcc_free_glz_drawable_instance(EncodersData *enc,
     if (ring_is_empty(&glz_drawable->instances)) {
         spice_assert(glz_drawable->instances_count == 0);
 
-        Drawable *drawable = glz_drawable->drawable;
-
-        if (drawable) {
+        if (glz_drawable->has_drawable) {
             ring_remove(&glz_drawable->drawable_link);
         }
         red_drawable_unref(glz_drawable->red_drawable);
@@ -564,7 +562,7 @@ int dcc_free_some_independent_glz_drawables(EncodersData *enc, int n)
     while ((n < RED_RELEASE_BUNCH_SIZE) && (ring_link != NULL)) {
         RedGlzDrawable *glz_drawable = SPICE_CONTAINEROF(ring_link, RedGlzDrawable, link);
         ring_link = ring_next(&enc->glz_drawables, ring_link);
-        if (!glz_drawable->drawable) {
+        if (!glz_drawable->has_drawable) {
             dcc_free_glz_drawable(enc, glz_drawable);
             n++;
         }
@@ -625,7 +623,7 @@ void dcc_glz_detach_from_drawable(struct Drawable *drawable)
     RingItem *item, *next;
 
     RING_FOREACH_SAFE(item, next, &drawable->glz_ring) {
-        SPICE_CONTAINEROF(item, RedGlzDrawable, drawable_link)->drawable = NULL;
+        SPICE_CONTAINEROF(item, RedGlzDrawable, drawable_link)->has_drawable = FALSE;
         ring_remove(item);
     }
 }
@@ -1143,7 +1141,7 @@ static RedGlzDrawable *get_glz_drawable(EncodersData *enc, Drawable *drawable)
 
     ret->encoders = enc;
     ret->red_drawable = red_drawable_ref(drawable->red_drawable);
-    ret->drawable = drawable;
+    ret->has_drawable = TRUE;
     ret->instances_count = 0;
     ring_init(&ret->instances);
 
-- 
2.7.4

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]