commit 2dcf94fae182f1cc856ef0a5984e636466da2009
parent 356b5c237f737dcb0399e0a26c27725d2f8af078
Author: sin <sin@2f30.org>
Date: Sat, 30 Mar 2019 16:03:38 +0000
Rename cache_node to node
Diffstat:
M | cache.c | | | 32 | ++++++++++++++++---------------- |
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/cache.c b/cache.c
@@ -8,18 +8,18 @@
#include "dedup.h"
#include "tree.h"
-struct cache_node {
+struct node {
struct blk_desc desc;
- RB_ENTRY(cache_node) e;
+ RB_ENTRY(node) e;
};
-RB_HEAD(cache_head, cache_node);
+RB_HEAD(cache_head, node);
struct cache {
struct cache_head nodes;
};
static int
-cache_node_cmp(struct cache_node *e1, struct cache_node *e2)
+node_cmp(struct node *e1, struct node *e2)
{
int r;
@@ -30,13 +30,13 @@ cache_node_cmp(struct cache_node *e1, struct cache_node *e2)
return -1;
return 0;
}
-static RB_PROTOTYPE(cache_head, cache_node, e, cache_node_cmp);
-static RB_GENERATE(cache_head, cache_node, e, cache_node_cmp);
+static RB_PROTOTYPE(cache_head, node, e, node_cmp);
+static RB_GENERATE(cache_head, node, e, node_cmp);
-static struct cache_node *
-alloc_cache_node(struct blk_desc *desc)
+static struct node *
+alloc_node(struct blk_desc *desc)
{
- struct cache_node *node;
+ struct node *node;
node = calloc(1, sizeof(*node));
if (node == NULL)
@@ -46,7 +46,7 @@ alloc_cache_node(struct blk_desc *desc)
}
static void
-free_cache_node(struct cache_node *node)
+free_node(struct node *node)
{
free(node);
}
@@ -66,11 +66,11 @@ alloc_cache(void)
void
free_cache(struct cache *cache)
{
- struct cache_node *node, *tmp;
+ struct node *node, *tmp;
RB_FOREACH_SAFE(node, cache_head, &cache->nodes, tmp) {
RB_REMOVE(cache_head, &cache->nodes, node);
- free_cache_node(node);
+ free_node(node);
}
free(cache);
}
@@ -78,17 +78,17 @@ free_cache(struct cache *cache)
void
add_cache_entry(struct cache *cache, struct blk_desc *desc)
{
- struct cache_node *node;
+ struct node *node;
- node = alloc_cache_node(desc);
+ node = alloc_node(desc);
if (RB_INSERT(cache_head, &cache->nodes, node) != NULL)
- free_cache_node(node);
+ free_node(node);
}
int
lookup_cache_entry(struct cache *cache, struct blk_desc *desc)
{
- struct cache_node *node, key;
+ struct node *node, key;
key.desc = *desc;
node = RB_FIND(cache_head, &cache->nodes, &key);