Skip to content

Commit

Permalink
lru_hashmap: make type name consistent (uppercase Map to lowercase map)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gottox committed Oct 16, 2021
1 parent f770e9d commit 0033c4b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions src/utils/lru_hashmap.c
Expand Up @@ -39,12 +39,12 @@
#include <stdlib.h>

static off_t
lru_hash_to_start_index(struct SquashLruHashMap *hashmap, uint64_t hash) {
lru_hash_to_start_index(struct SquashLruHashmap *hashmap, uint64_t hash) {
return (hash * hash) % hashmap->size;
}

int
squash_lru_hashmap_init(struct SquashLruHashMap *hashmap, size_t size,
squash_lru_hashmap_init(struct SquashLruHashmap *hashmap, size_t size,
SquashLruHashmapDtor dtor) {
hashmap->dtor = dtor;
hashmap->size = size;
Expand All @@ -60,7 +60,7 @@ squash_lru_hashmap_init(struct SquashLruHashMap *hashmap, size_t size,
}
int
squash_lru_hashmap_put(
struct SquashLruHashMap *hashmap, uint64_t hash, void *pointer) {
struct SquashLruHashmap *hashmap, uint64_t hash, void *pointer) {
off_t start_index = lru_hash_to_start_index(hashmap, hash);
struct SquashLruEntry *candidate = NULL;

Expand Down Expand Up @@ -112,7 +112,7 @@ squash_lru_hashmap_put(
return 0;
}
void *
squash_lru_hashmap_get(struct SquashLruHashMap *hashmap, uint64_t hash) {
squash_lru_hashmap_get(struct SquashLruHashmap *hashmap, uint64_t hash) {
off_t start_index = lru_hash_to_start_index(hashmap, hash);

for (off_t i = 0; i < hashmap->size; i++) {
Expand All @@ -130,7 +130,7 @@ squash_lru_hashmap_get(struct SquashLruHashMap *hashmap, uint64_t hash) {
}

int
squash_lru_hashmap_cleanup(struct SquashLruHashMap *hashmap) {
squash_lru_hashmap_cleanup(struct SquashLruHashmap *hashmap) {
for (int i = 0; i < hashmap->size; i++) {
if (hashmap->entries[i].pointer != NULL) {
hashmap->dtor(&hashmap->entries[i]);
Expand Down
10 changes: 5 additions & 5 deletions src/utils/lru_hashmap.h
Expand Up @@ -49,19 +49,19 @@ struct SquashLruEntry {
uint64_t hash;
};

struct SquashLruHashMap {
struct SquashLruHashmap {
size_t size;
struct SquashLruEntry *oldest;
struct SquashLruEntry *newest;
struct SquashLruEntry *entries;
SquashLruHashmapDtor dtor;
};

SQUASH_NO_UNUSED int squash_lru_hashmap_init(struct SquashLruHashMap *hashmap,
SQUASH_NO_UNUSED int squash_lru_hashmap_init(struct SquashLruHashmap *hashmap,
size_t size, SquashLruHashmapDtor dtor);
SQUASH_NO_UNUSED int squash_lru_hashmap_put(
struct SquashLruHashMap *hashmap, uint64_t hash, void *pointer);
void *squash_lru_hashmap_get(struct SquashLruHashMap *hashmap, uint64_t hash);
int squash_lru_hashmap_cleanup(struct SquashLruHashMap *hashmap);
struct SquashLruHashmap *hashmap, uint64_t hash, void *pointer);
void *squash_lru_hashmap_get(struct SquashLruHashmap *hashmap, uint64_t hash);
int squash_lru_hashmap_cleanup(struct SquashLruHashmap *hashmap);

#endif /* end of include guard LRU_HASHMAP_H */
12 changes: 6 additions & 6 deletions test/utils/lru_hashmap.c
Expand Up @@ -54,7 +54,7 @@ dummy_dtor(void *pointer) {
static void
init_hashmap() {
int rv = 0;
struct SquashLruHashMap hashmap = {0};
struct SquashLruHashmap hashmap = {0};

rv = squash_lru_hashmap_init(&hashmap, 1024, dummy_dtor);
assert(rv == 0);
Expand All @@ -65,7 +65,7 @@ init_hashmap() {
static void
add_to_hashmap() {
int rv = 0;
struct SquashLruHashMap hashmap = {0};
struct SquashLruHashmap hashmap = {0};
char *v1 = "Value1";
char *v2 = "Value2";

Expand All @@ -83,7 +83,7 @@ add_to_hashmap() {
static void
read_from_hashmap() {
int rv = 0;
struct SquashLruHashMap hashmap = {0};
struct SquashLruHashmap hashmap = {0};
char *v1 = "Value1";
char *v2 = "Value2";
char *p;
Expand All @@ -107,7 +107,7 @@ read_from_hashmap() {
static void
hashmap_overflow() {
int rv = 0;
struct SquashLruHashMap hashmap = {0};
struct SquashLruHashmap hashmap = {0};
char *v1 = "Value1";
char *v2 = "Value2";
char *v3 = "Value3";
Expand Down Expand Up @@ -158,7 +158,7 @@ hashmap_add_many() {
const int NBR = 2048, SIZE = 512;
int rv = 0;
int length = 0;
struct SquashLruHashMap hashmap = {0};
struct SquashLruHashmap hashmap = {0};
int values[NBR];

rv = squash_lru_hashmap_init(&hashmap, SIZE, dtor);
Expand Down Expand Up @@ -206,7 +206,7 @@ hashmap_add_many() {
static void
hashmap_size_1() {
int rv = 0;
struct SquashLruHashMap hashmap = {0};
struct SquashLruHashmap hashmap = {0};
char *v1 = "Value1";
char *v2 = "Value2";
char *p;
Expand Down

0 comments on commit 0033c4b

Please sign in to comment.