[Spice-devel] [PATCH 2/4] Move RedCacheItem size field inside cache_data union

Jonathon Jongsma jjongsma at redhat.com
Tue May 24 21:30:59 UTC 2016


Oops. one minor problem. Typo in commit log: clean -> clear

On Tue, 2016-05-24 at 15:09 -0500, Jonathon Jongsma wrote:
> OK. But this is a pretty odd struct...
> 
> Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
> 
> 
> 
> On Tue, 2016-05-24 at 15:55 +0100, Frediano Ziglio wrote:
> > This reduce a bit the structure size and make clean that
> > the field is used only when the item is a cache item.
> > 
> > Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> > ---
> >  server/cache-item.h      | 2 +-
> >  server/cache-item.tmpl.c | 4 ++--
> >  2 files changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/server/cache-item.h b/server/cache-item.h
> > index 864b163..af0fc9e 100644
> > --- a/server/cache-item.h
> > +++ b/server/cache-item.h
> > @@ -30,10 +30,10 @@ struct RedCacheItem {
> >          struct {
> >              RingItem lru_link;
> >              RedCacheItem *next;
> > +            size_t size;
> >          } cache_data;
> >      } u;
> >      uint64_t id;
> > -    size_t size;
> >  };
> >  
> >  #endif /* CACHE_ITEM_H_ */
> > diff --git a/server/cache-item.tmpl.c b/server/cache-item.tmpl.c
> > index 2cf12d8..9a9181c 100644
> > --- a/server/cache-item.tmpl.c
> > +++ b/server/cache-item.tmpl.c
> > @@ -77,7 +77,7 @@ static void FUNC_NAME(remove)(CHANNELCLIENT
> > *channel_client,
> > RedCacheItem *item)
> >      }
> >      ring_remove(&item->u.cache_data.lru_link);
> >      channel_client->VAR_NAME(items)--;
> > -    channel_client->VAR_NAME(available) += item->size;
> > +    channel_client->VAR_NAME(available) += item->u.cache_data.size;
> >  
> >      red_pipe_item_init(&item->u.pipe_data, RED_PIPE_ITEM_TYPE_INVAL_ONE);
> >      red_channel_client_pipe_add_tail_and_push(&channel_client->common.base,
> > &item->u.pipe_data); // for now
> > @@ -107,7 +107,7 @@ static int FUNC_NAME(add)(CHANNELCLIENT *channel_client,
> > uint64_t id, size_t siz
> >      ring_item_init(&item->u.cache_data.lru_link);
> >      ring_add(&channel_client->VAR_NAME(lru), &item->u.cache_data.lru_link);
> >      item->id = id;
> > -    item->size = size;
> > +    item->u.cache_data.size = size;
> >      return TRUE;
> >  }
> >  
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


More information about the Spice-devel mailing list