[Spice-devel] [PATCH v2 25/30] Change RedGlzDrawable::drawable from pointer to boolean
Frediano Ziglio
fziglio at redhat.com
Thu Jun 9 12:31:45 UTC 2016
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 at redhat.com>
---
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 dcefecd..e768e08 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;
ImageEncoders *encoders;
};
@@ -502,9 +502,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);
@@ -565,7 +563,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++;
}
@@ -626,7 +624,7 @@ void image_encoders_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);
}
}
@@ -1144,7 +1142,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);
--
2.7.4
More information about the Spice-devel
mailing list