summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/catalog.c11
-rw-r--r--src/journal/catalog.h3
-rw-r--r--src/journal/coredump-vacuum.c2
-rw-r--r--src/journal/coredumpctl.c2
-rw-r--r--src/journal/journal-file.c2
-rw-r--r--src/journal/journalctl.c2
-rw-r--r--src/journal/journald-server.c2
-rw-r--r--src/journal/mmap-cache.c4
-rw-r--r--src/journal/sd-journal.c8
-rw-r--r--src/journal/test-catalog.c2
10 files changed, 21 insertions, 17 deletions
diff --git a/src/journal/catalog.c b/src/journal/catalog.c
index f03357dedf..41d450b154 100644
--- a/src/journal/catalog.c
+++ b/src/journal/catalog.c
@@ -64,7 +64,7 @@ typedef struct CatalogItem {
le64_t offset;
} CatalogItem;
-unsigned long catalog_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) {
+static unsigned long catalog_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) {
const CatalogItem *i = p;
uint64_t u;
size_t l, sz;
@@ -81,7 +81,7 @@ unsigned long catalog_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_S
return (unsigned long) u;
}
-int catalog_compare_func(const void *a, const void *b) {
+static int catalog_compare_func(const void *a, const void *b) {
const CatalogItem *i = a, *j = b;
unsigned k;
@@ -95,6 +95,11 @@ int catalog_compare_func(const void *a, const void *b) {
return strcmp(i->language, j->language);
}
+const struct hash_ops catalog_hash_ops = {
+ .hash = catalog_hash_func,
+ .compare = catalog_compare_func
+};
+
static int finish_item(
Hashmap *h,
struct strbuf *sb,
@@ -407,7 +412,7 @@ int catalog_update(const char* database, const char* root, const char* const* di
unsigned n;
long r;
- h = hashmap_new(catalog_hash_func, catalog_compare_func);
+ h = hashmap_new(&catalog_hash_ops);
sb = strbuf_new();
if (!h || !sb) {
diff --git a/src/journal/catalog.h b/src/journal/catalog.h
index fdde67aeed..a72ecf6de7 100644
--- a/src/journal/catalog.h
+++ b/src/journal/catalog.h
@@ -28,11 +28,10 @@
#include "strbuf.h"
int catalog_import_file(Hashmap *h, struct strbuf *sb, const char *path);
-unsigned long catalog_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]);
-int catalog_compare_func(const void *a, const void *b) _pure_;
int catalog_update(const char* database, const char* root, const char* const* dirs);
int catalog_get(const char* database, sd_id128_t id, char **data);
int catalog_list(FILE *f, const char* database, bool oneline);
int catalog_list_items(FILE *f, const char* database, bool oneline, char **items);
int catalog_file_lang(const char *filename, char **lang);
extern const char * const catalog_file_dirs[];
+extern const struct hash_ops catalog_hash_ops;
diff --git a/src/journal/coredump-vacuum.c b/src/journal/coredump-vacuum.c
index 125bb3a4b8..fec901e8e4 100644
--- a/src/journal/coredump-vacuum.c
+++ b/src/journal/coredump-vacuum.c
@@ -194,7 +194,7 @@ int coredump_vacuum(int exclude_fd, off_t keep_free, off_t max_use) {
exclude_st.st_ino == st.st_ino)
continue;
- r = hashmap_ensure_allocated(&h, NULL, NULL);
+ r = hashmap_ensure_allocated(&h, NULL);
if (r < 0)
return log_oom();
diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c
index 34dcae87c0..d4756fe67d 100644
--- a/src/journal/coredumpctl.c
+++ b/src/journal/coredumpctl.c
@@ -58,7 +58,7 @@ static Set *new_matches(void) {
char *tmp;
int r;
- set = set_new(trivial_hash_func, trivial_compare_func);
+ set = set_new(NULL);
if (!set) {
log_oom();
return NULL;
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 7286e14ddb..f25cda6ddc 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -2498,7 +2498,7 @@ int journal_file_open(
goto fail;
}
- f->chain_cache = hashmap_new(uint64_hash_func, uint64_compare_func);
+ f->chain_cache = hashmap_new(&uint64_hash_ops);
if (!f->chain_cache) {
r = -ENOMEM;
goto fail;
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index d00a815ba9..47206d383a 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -1029,7 +1029,7 @@ static int get_possible_units(sd_journal *j,
const char *field;
int r;
- found = set_new(string_hash_func, string_compare_func);
+ found = set_new(&string_hash_ops);
if (!found)
return log_oom();
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index 01da38b8d8..3df7416397 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -1483,7 +1483,7 @@ int server_init(Server *s) {
mkdir_p("/run/systemd/journal", 0755);
- s->user_journals = hashmap_new(trivial_hash_func, trivial_compare_func);
+ s->user_journals = hashmap_new(NULL);
if (!s->user_journals)
return log_oom();
diff --git a/src/journal/mmap-cache.c b/src/journal/mmap-cache.c
index 908562da27..2d268fc332 100644
--- a/src/journal/mmap-cache.c
+++ b/src/journal/mmap-cache.c
@@ -227,7 +227,7 @@ static Context *context_add(MMapCache *m, unsigned id) {
if (c)
return c;
- r = hashmap_ensure_allocated(&m->contexts, trivial_hash_func, trivial_compare_func);
+ r = hashmap_ensure_allocated(&m->contexts, NULL);
if (r < 0)
return NULL;
@@ -281,7 +281,7 @@ static FileDescriptor* fd_add(MMapCache *m, int fd) {
if (f)
return f;
- r = hashmap_ensure_allocated(&m->fds, trivial_hash_func, trivial_compare_func);
+ r = hashmap_ensure_allocated(&m->fds, NULL);
if (r < 0)
return NULL;
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index 693707cb34..1fc9f01d0a 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -70,7 +70,7 @@ static int set_put_error(sd_journal *j, int r) {
if (r >= 0)
return r;
- k = set_ensure_allocated(&j->errors, trivial_hash_func, trivial_compare_func);
+ k = set_ensure_allocated(&j->errors, NULL);
if (k < 0)
return k;
@@ -1662,7 +1662,7 @@ static int allocate_inotify(sd_journal *j) {
}
if (!j->directories_by_wd) {
- j->directories_by_wd = hashmap_new(trivial_hash_func, trivial_compare_func);
+ j->directories_by_wd = hashmap_new(NULL);
if (!j->directories_by_wd)
return -ENOMEM;
}
@@ -1688,8 +1688,8 @@ static sd_journal *journal_new(int flags, const char *path) {
goto fail;
}
- j->files = hashmap_new(string_hash_func, string_compare_func);
- j->directories_by_path = hashmap_new(string_hash_func, string_compare_func);
+ j->files = hashmap_new(&string_hash_ops);
+ j->directories_by_path = hashmap_new(&string_hash_ops);
j->mmap = mmap_cache_new();
if (!j->files || !j->directories_by_path || !j->mmap)
goto fail;
diff --git a/src/journal/test-catalog.c b/src/journal/test-catalog.c
index 967ab6756b..5fe2f6a269 100644
--- a/src/journal/test-catalog.c
+++ b/src/journal/test-catalog.c
@@ -62,7 +62,7 @@ static void test_catalog_importing(void) {
Hashmap *h;
struct strbuf *sb;
- assert_se(h = hashmap_new(catalog_hash_func, catalog_compare_func));
+ assert_se(h = hashmap_new(&catalog_hash_ops));
assert_se(sb = strbuf_new());
#define BUF "xxx"