[Spice-devel] [PATCH v4 13/19] Change RedGlzDrawable::drawable from pointer to boolean
Jonathon Jongsma
jjongsma at redhat.com
Tue Jun 14 21:32:56 UTC 2016
On Tue, 2016-06-14 at 10:33 +0100, Frediano Ziglio wrote:
> 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.
s/many/makes/
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
>
> 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 22cfcf3..00349fe 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;
> };
>
> @@ -505,9 +505,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);
> @@ -569,7 +567,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++;
> }
> @@ -630,7 +628,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);
> }
> }
> @@ -1143,7 +1141,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);
>
More information about the Spice-devel
mailing list