From 49e2899ea835f1a5a0ffd4637e1cc5a2f728a5d2 Mon Sep 17 00:00:00 2001 From: Frediano Ziglio Date: Tue, 7 Jun 2016 08:39:48 +0100 Subject: [PATCH] Change RedGlzDrawable::drawable from pointer to boolean 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 makes the structure a bit smaller. Signed-off-by: Frediano Ziglio Acked-by: Jonathon Jongsma --- server/dcc-encoders.c | 8 +++----- server/dcc-encoders.h | 2 +- server/display-channel.c | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c index 596d07a3..e4e426dd 100644 --- a/server/dcc-encoders.c +++ b/server/dcc-encoders.c @@ -469,9 +469,7 @@ static void image_encoders_free_glz_drawable_instance(ImageEncoders *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); @@ -533,7 +531,7 @@ int image_encoders_free_some_independent_glz_drawables(ImageEncoders *enc) 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) { image_encoders_free_glz_drawable(enc, glz_drawable); n++; } @@ -1078,7 +1076,7 @@ static RedGlzDrawable *get_glz_drawable(ImageEncoders *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); diff --git a/server/dcc-encoders.h b/server/dcc-encoders.h index bd761a68..b761f33b 100644 --- a/server/dcc-encoders.h +++ b/server/dcc-encoders.h @@ -160,10 +160,10 @@ struct RedGlzDrawable { RingItem link; // ordered by the time it was encoded RingItem drawable_link; RedDrawable *red_drawable; - Drawable *drawable; GlzDrawableInstanceItem instances_pool[MAX_GLZ_DRAWABLE_INSTANCES]; Ring instances; uint8_t instances_count; + gboolean has_drawable; ImageEncoders *encoders; }; diff --git a/server/display-channel.c b/server/display-channel.c index 6dce8316..1dc0d298 100644 --- a/server/display-channel.c +++ b/server/display-channel.c @@ -1354,7 +1354,7 @@ void drawable_unref(Drawable *drawable) display_channel_surface_unref(display, drawable->surface_id); 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); } if (drawable->red_drawable) {