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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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;
 }
 
-- 
2.7.4

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]