[Spice-devel] [PATCH v2 08/10] Add DisplayChannelClientPrivate and CursorChannelPrivate structs
Frediano Ziglio
fziglio at redhat.com
Thu Sep 8 08:35:04 UTC 2016
>
> These need to be introduced at the same time since cache-item.tmpl.c
> assumes that both of these classes will have a cache in the same place:
> either within the channel client struct itself or (now) within a priv
> struct owned by the channel client.
>
> This encapsulates private data and prepares for porting to GObject.
> ---
> Changes in v2:
> - Fixed leak of priv by using 1-element array trick
>
> server/cache-item.tmpl.c | 38 +++++-----
> server/cursor-channel-client.c | 16 ++--
> server/dcc-private.h | 14 +++-
> server/dcc-send.c | 114 ++++++++++++++--------------
> server/dcc.c | 165
> +++++++++++++++++++++--------------------
> 5 files changed, 182 insertions(+), 165 deletions(-)
>
> diff --git a/server/cache-item.tmpl.c b/server/cache-item.tmpl.c
> index d1310a5..ce38a2a 100644
> --- a/server/cache-item.tmpl.c
> +++ b/server/cache-item.tmpl.c
> @@ -46,12 +46,12 @@
>
> static RedCacheItem *FUNC_NAME(find)(CHANNELCLIENT *channel_client, uint64_t
> id)
> {
> - RedCacheItem *item = channel_client->CACHE_NAME[CACHE_HASH_KEY(id)];
> + RedCacheItem *item =
> channel_client->priv->CACHE_NAME[CACHE_HASH_KEY(id)];
>
> while (item) {
> if (item->id == id) {
> ring_remove(&item->u.cache_data.lru_link);
> - ring_add(&channel_client->VAR_NAME(lru),
> &item->u.cache_data.lru_link);
> + ring_add(&channel_client->priv->VAR_NAME(lru),
> &item->u.cache_data.lru_link);
> break;
> }
> item = item->u.cache_data.next;
> @@ -64,7 +64,7 @@ static void FUNC_NAME(remove)(CHANNELCLIENT
> *channel_client, RedCacheItem *item)
> RedCacheItem **now;
> spice_assert(item);
>
> - now = &channel_client->CACHE_NAME[CACHE_HASH_KEY(item->id)];
> + now = &channel_client->priv->CACHE_NAME[CACHE_HASH_KEY(item->id)];
> for (;;) {
> spice_assert(*now);
> if (*now == item) {
> @@ -74,8 +74,8 @@ static void FUNC_NAME(remove)(CHANNELCLIENT
> *channel_client, RedCacheItem *item)
> now = &(*now)->u.cache_data.next;
> }
> ring_remove(&item->u.cache_data.lru_link);
> - channel_client->VAR_NAME(items)--;
> - channel_client->VAR_NAME(available) += item->u.cache_data.size;
...
Acked-by: Frediano Ziglio <fziglio at redhat.com
Frediano
More information about the Spice-devel
mailing list