dedup

data deduplication program
git clone git://git.2f30.org/dedup.git
Log | Files | Refs | README | LICENSE

commit c4cfb879017085a6206af8838fb4f69c4a7713d1
parent 144b179f6b08a913d12290dc05606eee21e757de
Author: sin <sin@2f30.org>
Date:   Mon, 25 Feb 2019 14:54:58 +0000

Re-order funcs

Diffstat:
Mcache.c | 48++++++++++++++++++++++++------------------------
Mdedup.h | 4++--
2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/cache.c b/cache.c @@ -53,6 +53,30 @@ free_cache_node(struct cache_node *node) free(node); } +struct cache * +alloc_cache(void) +{ + struct cache *cache; + + cache = calloc(1, sizeof(*cache)); + if (cache == NULL) + err(1, "malloc"); + RB_INIT(&cache->nodes); + return cache; +} + +void +free_cache(struct cache *cache) +{ + struct cache_node *node, *tmp; + + RB_FOREACH_SAFE(node, cache_head, &cache->nodes, tmp) { + RB_REMOVE(cache_head, &cache->nodes, node); + free_cache_node(node); + } + free(cache); +} + void add_cache_entry(struct cache *cache, struct cache_entry *ent) { @@ -84,27 +108,3 @@ walk_cache(struct cache *cache, int (*fn)(struct cache_entry *)) RB_FOREACH(node, cache_head, &cache->nodes) (*fn)(&node->ent); } - -struct cache * -alloc_cache(void) -{ - struct cache *cache; - - cache = calloc(1, sizeof(*cache)); - if (cache == NULL) - err(1, "malloc"); - RB_INIT(&cache->nodes); - return cache; -} - -void -free_cache(struct cache *cache) -{ - struct cache_node *node, *tmp; - - RB_FOREACH_SAFE(node, cache_head, &cache->nodes, tmp) { - RB_REMOVE(cache_head, &cache->nodes, node); - free_cache_node(node); - } - free(cache); -} diff --git a/dedup.h b/dedup.h @@ -49,11 +49,11 @@ struct cache_entry { }; /* cache.c */ +struct cache *alloc_cache(void); +void free_cache(struct cache *cache); void add_cache_entry(struct cache *cache, struct cache_entry *ent); int lookup_cache_entry(struct cache *cache, struct cache_entry *ent); void walk_cache(struct cache *cache, int (*fn)(struct cache_entry *)); -struct cache *alloc_cache(void); -void free_cache(struct cache *cache); /* chunker.c */ struct chunker *alloc_chunker(size_t cap, int fd);