From 29b1fb689c71837616023b3adc78eda3d32026b2 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Mon, 25 Apr 2022 20:03:04 +0200 Subject: Removed size argument to `i_hash` template parameter and `c_default_hash`. This was a "design error", and is not worth keeping for backward compability. Please update your code where you use i_hash template parameter (simply remove second argument). --- examples/box.c | 4 ++-- examples/city.c | 4 ++-- examples/person_arc.c | 4 ++-- examples/rawptr_elements.c | 2 +- examples/vikings.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'examples') diff --git a/examples/box.c b/examples/box.c index 4a43b149..c50ced1e 100644 --- a/examples/box.c +++ b/examples/box.c @@ -7,8 +7,8 @@ Person Person_new(const char* name, const char* last) { return (Person){.name = cstr_from(name), .last = cstr_from(last)}; } -uint64_t Person_hash(const Person* a, size_t n) { - return cstr_hash(&a->name, 0) ^ cstr_hash(&a->last, 0); +uint64_t Person_hash(const Person* a) { + return cstr_hash(&a->name) ^ cstr_hash(&a->last); } int Person_cmp(const Person* a, const Person* b) { diff --git a/examples/city.c b/examples/city.c index 0e1cbe96..d1bee4b7 100644 --- a/examples/city.c +++ b/examples/city.c @@ -12,8 +12,8 @@ static inline int City_cmp(const City* a, const City* b) { return c ? c : cstr_cmp(&a->country, &b->country); } -static inline uint64_t City_hash(const City* a, size_t n) { - return cstr_hash(&a->name, 0) ^ cstr_hash(&a->country, 0); +static inline uint64_t City_hash(const City* a) { + return cstr_hash(&a->name) ^ cstr_hash(&a->country); } static inline City City_clone(City c) { diff --git a/examples/person_arc.c b/examples/person_arc.c index 9d245340..3e3f662f 100644 --- a/examples/person_arc.c +++ b/examples/person_arc.c @@ -12,8 +12,8 @@ int Person_cmp(const Person* a, const Person* b) { return c ? c : cstr_cmp(&a->last, &b->last); } -uint64_t Person_hash(const Person* a, size_t n) { - return cstr_hash(&a->name, 0) ^ cstr_hash(&a->last, 0); +uint64_t Person_hash(const Person* a) { + return cstr_hash(&a->name) ^ cstr_hash(&a->last); } Person Person_clone(Person p) { diff --git a/examples/rawptr_elements.c b/examples/rawptr_elements.c index 20231528..a1344ea7 100644 --- a/examples/rawptr_elements.c +++ b/examples/rawptr_elements.c @@ -8,7 +8,7 @@ struct { double x, y; } typedef Point; #define i_key Point* #define i_keydrop(x) c_free(*(x)) #define i_keyfrom(x) c_new(Point, *(x)) -#define i_hash(x, n) c_default_hash(*(x), sizeof **(x)) +#define i_hash(x) c_default_hash(*(x)) #define i_cmp(x, y) memcmp(*(x), *(y), sizeof **(x)) // not good! #define i_tag pnt #include diff --git a/examples/vikings.c b/examples/vikings.c index ff2fe8ab..51ab92f8 100644 --- a/examples/vikings.c +++ b/examples/vikings.c @@ -18,7 +18,7 @@ typedef struct RViking { const char* country; } RViking; -uint64_t RViking_hash(const RViking* raw, size_t ignore) { +uint64_t RViking_hash(const RViking* raw) { uint64_t hash = c_strhash(raw->name) ^ (c_strhash(raw->country) >> 15); return hash; } -- cgit v1.2.3