tree-wide: make hash_ops typesafe

This commit is contained in:
Yu Watanabe
2018-12-02 07:53:27 +01:00
parent 25073e5012
commit 7a08d314f2
27 changed files with 85 additions and 223 deletions
+5 -9
View File
@@ -460,8 +460,7 @@ finish:
return 0;
}
void dns_name_hash_func(const void *s, struct siphash *state) {
const char *p = s;
void dns_name_hash_func(const char *p, struct siphash *state) {
int r;
assert(p);
@@ -484,15 +483,15 @@ void dns_name_hash_func(const void *s, struct siphash *state) {
string_hash_func("", state);
}
int dns_name_compare_func(const void *a, const void *b) {
int dns_name_compare_func(const char *a, const char *b) {
const char *x, *y;
int r, q;
assert(a);
assert(b);
x = (const char *) a + strlen(a);
y = (const char *) b + strlen(b);
x = a + strlen(a);
y = b + strlen(b);
for (;;) {
char la[DNS_LABEL_MAX], lb[DNS_LABEL_MAX];
@@ -511,10 +510,7 @@ int dns_name_compare_func(const void *a, const void *b) {
}
}
const struct hash_ops dns_name_hash_ops = {
.hash = dns_name_hash_func,
.compare = dns_name_compare_func
};
DEFINE_HASH_OPS(dns_name_hash_ops, char, dns_name_hash_func, dns_name_compare_func);
int dns_name_equal(const char *x, const char *y) {
int r, q;
+2 -2
View File
@@ -57,8 +57,8 @@ static inline int dns_name_is_valid(const char *s) {
return 1;
}
void dns_name_hash_func(const void *s, struct siphash *state);
int dns_name_compare_func(const void *a, const void *b);
void dns_name_hash_func(const char *s, struct siphash *state);
int dns_name_compare_func(const char *a, const char *b);
extern const struct hash_ops dns_name_hash_ops;
int dns_name_between(const char *a, const char *b, const char *c);