X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fgit.git;a=blobdiff_plain;f=packfile.c;h=355066de17514e1a2cf8456e6d55d871bf15f09b;hp=dd4b0e51c4956f9ce2da5e9bd1d970e31a8b6d92;hb=51728480fe0639e918927dedb3bb6b933c588fae;hpb=4608a029b490a87469680ee7d055a6d7cb5912c6 diff --git a/packfile.c b/packfile.c index dd4b0e51c4..355066de17 100644 --- a/packfile.c +++ b/packfile.c @@ -6,7 +6,6 @@ #include "mergesort.h" #include "packfile.h" #include "delta.h" -#include "list.h" #include "streaming.h" #include "sha1-lookup.h" #include "commit.h" @@ -1344,7 +1343,7 @@ struct delta_base_cache_key { }; struct delta_base_cache_entry { - struct hashmap hash; + struct hashmap_entry ent; struct delta_base_cache_key key; struct list_head lru; void *data; @@ -1364,7 +1363,7 @@ static unsigned int pack_entry_hash(struct packed_git *p, off_t base_offset) static struct delta_base_cache_entry * get_delta_base_cache_entry(struct packed_git *p, off_t base_offset) { - struct hashmap_entry entry; + struct hashmap_entry entry, *e; struct delta_base_cache_key key; if (!delta_base_cache.cmpfn) @@ -1373,7 +1372,8 @@ get_delta_base_cache_entry(struct packed_git *p, off_t base_offset) hashmap_entry_init(&entry, pack_entry_hash(p, base_offset)); key.p = p; key.base_offset = base_offset; - return hashmap_get(&delta_base_cache, &entry, &key); + e = hashmap_get(&delta_base_cache, &entry, &key); + return e ? container_of(e, struct delta_base_cache_entry, ent) : NULL; } static int delta_base_cache_key_eq(const struct delta_base_cache_key *a, @@ -1383,11 +1383,16 @@ static int delta_base_cache_key_eq(const struct delta_base_cache_key *a, } static int delta_base_cache_hash_cmp(const void *unused_cmp_data, - const void *va, const void *vb, + const struct hashmap_entry *va, + const struct hashmap_entry *vb, const void *vkey) { - const struct delta_base_cache_entry *a = va, *b = vb; + const struct delta_base_cache_entry *a, *b; const struct delta_base_cache_key *key = vkey; + + a = container_of(va, const struct delta_base_cache_entry, ent); + b = container_of(vb, const struct delta_base_cache_entry, ent); + if (key) return !delta_base_cache_key_eq(&a->key, key); else @@ -1406,7 +1411,7 @@ static int in_delta_base_cache(struct packed_git *p, off_t base_offset) */ static void detach_delta_base_cache_entry(struct delta_base_cache_entry *ent) { - hashmap_remove(&delta_base_cache, ent, &ent->key); + hashmap_remove(&delta_base_cache, &ent->ent, &ent->key); list_del(&ent->lru); delta_base_cached -= ent->size; free(ent); @@ -1470,8 +1475,8 @@ static void add_delta_base_cache(struct packed_git *p, off_t base_offset, if (!delta_base_cache.cmpfn) hashmap_init(&delta_base_cache, delta_base_cache_hash_cmp, NULL, 0); - hashmap_entry_init(ent, pack_entry_hash(p, base_offset)); - hashmap_add(&delta_base_cache, ent); + hashmap_entry_init(&ent->ent, pack_entry_hash(p, base_offset)); + hashmap_add(&delta_base_cache, &ent->ent); } int packed_object_info(struct repository *r, struct packed_git *p,