siphash24_compress(p, strlen(p) + 1, state);
}
-DEFINE_HASH_OPS(string_hash_ops, char, string_hash_func, string_compare_func);
-DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(string_hash_ops_free,
- char, string_hash_func, string_compare_func, free);
-DEFINE_HASH_OPS_FULL(string_hash_ops_free_free,
- char, string_hash_func, string_compare_func, free,
- void, free);
-DEFINE_HASH_OPS_FULL(string_hash_ops_free_strv_free,
- char, string_hash_func, string_compare_func, free,
- char*, strv_free);
+DEFINE_HASH_OPS(string_hash_ops,
+ char, string_hash_func, string_compare_func);
+DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(
+ string_hash_ops_free,
+ char, string_hash_func, string_compare_func, free);
+DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
+ string_hash_ops_value_free,
+ char, string_hash_func, string_compare_func,
+ void, free);
+DEFINE_HASH_OPS_FULL(
+ string_hash_ops_free_free,
+ char, string_hash_func, string_compare_func, free,
+ void, free);
+DEFINE_HASH_OPS_FULL(
+ string_hash_ops_free_strv_free,
+ char, string_hash_func, string_compare_func, free,
+ char*, strv_free);
void path_hash_func(const char *q, struct siphash *state) {
bool add_slash = false;
}
}
-DEFINE_HASH_OPS(path_hash_ops, char, path_hash_func, path_compare);
-DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(path_hash_ops_free,
- char, path_hash_func, path_compare, free);
-DEFINE_HASH_OPS_FULL(path_hash_ops_free_free,
- char, path_hash_func, path_compare, free,
- void, free);
+DEFINE_HASH_OPS(path_hash_ops,
+ char, path_hash_func, path_compare);
+DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(
+ path_hash_ops_free,
+ char, path_hash_func, path_compare, free);
+DEFINE_HASH_OPS_FULL(
+ path_hash_ops_free_free,
+ char, path_hash_func, path_compare, free,
+ void, free);
void trivial_hash_func(const void *p, struct siphash *state) {
siphash24_compress_typesafe(p, state);
return CMP(a, b);
}
-const struct hash_ops trivial_hash_ops = {
- .hash = trivial_hash_func,
- .compare = trivial_compare_func,
-};
-
-const struct hash_ops trivial_hash_ops_free = {
- .hash = trivial_hash_func,
- .compare = trivial_compare_func,
- .free_key = free,
-};
-
-const struct hash_ops trivial_hash_ops_free_free = {
- .hash = trivial_hash_func,
- .compare = trivial_compare_func,
- .free_key = free,
- .free_value = free,
-};
+DEFINE_HASH_OPS(trivial_hash_ops,
+ void, trivial_hash_func, trivial_compare_func);
+DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(
+ trivial_hash_ops_free,
+ void, trivial_hash_func, trivial_compare_func, free);
+DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
+ trivial_hash_ops_value_free,
+ void, trivial_hash_func, trivial_compare_func,
+ void, free);
+DEFINE_HASH_OPS_FULL(
+ trivial_hash_ops_free_free,
+ void, trivial_hash_func, trivial_compare_func, free,
+ void, free);
void uint64_hash_func(const uint64_t *p, struct siphash *state) {
siphash24_compress_typesafe(*p, state);
return CMP(*a, *b);
}
-DEFINE_HASH_OPS(uint64_hash_ops, uint64_t, uint64_hash_func, uint64_compare_func);
+DEFINE_HASH_OPS(uint64_hash_ops,
+ uint64_t, uint64_hash_func, uint64_compare_func);
+DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
+ uint64_hash_ops_value_free,
+ uint64_t, uint64_hash_func, uint64_compare_func,
+ void, free);
#if SIZEOF_DEV_T != 8
void devt_hash_func(const dev_t *p, struct siphash *state) {
#define string_compare_func strcmp
extern const struct hash_ops string_hash_ops;
extern const struct hash_ops string_hash_ops_free;
+extern const struct hash_ops string_hash_ops_value_free;
extern const struct hash_ops string_hash_ops_free_free;
extern const struct hash_ops string_hash_ops_free_strv_free;
int trivial_compare_func(const void *a, const void *b) _const_;
extern const struct hash_ops trivial_hash_ops;
extern const struct hash_ops trivial_hash_ops_free;
+extern const struct hash_ops trivial_hash_ops_value_free;
extern const struct hash_ops trivial_hash_ops_free_free;
/* 32-bit values we can always just embed in the pointer itself, but in order to support 32-bit archs we need store 64-bit
void uint64_hash_func(const uint64_t *p, struct siphash *state);
int uint64_compare_func(const uint64_t *a, const uint64_t *b) _pure_;
extern const struct hash_ops uint64_hash_ops;
+extern const struct hash_ops uint64_hash_ops_value_free;
/* On some archs dev_t is 32-bit, and on others 64-bit. And sometimes it's 64-bit on 32-bit archs, and sometimes 32-bit on
* 64-bit archs. Yuck! */