Re: [PATCH v2 07/19] hashmap_get takes "const struct hashmap_entry *"
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Sep 25, 2019, 12:52 UTC
- Message-ID
- <9dc71ed0-617c-84e8-b7fc-0766f4d83695@gmail.com>
- In-Reply-To
- <20190924010324.22619-8-e@80x24.org>
On 9/23/2019 9:03 PM, Eric Wong wrote:
> This is less error-prone than "const void *" as the compiler > now detects invalid types being passed.
[snip]
Show 31 quoted lines
> diff --git a/hashmap.h b/hashmap.h
> index 40bcc64289..2a4b4a3954 100644
> --- a/hashmap.h
> +++ b/hashmap.h
> @@ -74,7 +74,8 @@
> * e->key = key;
> *
> * flags |= COMPARE_VALUE;
> - * printf("%sfound\n", hashmap_get(&map, e, NULL) ? "" : "not ");
> + * printf("%sfound\n",
> + * hashmap_get(&map, &e->ent, NULL) ? "" : "not ");
> * free(e);
> * }
> *
> @@ -84,7 +85,8 @@
> * k.key = key;
> *
> * flags |= COMPARE_VALUE;
> - * printf("%sfound\n", hashmap_get(&map, &k, value) ? "" : "not ");
> + * printf("%sfound\n",
> + * hashmap_get(&map, &k->ent, value) ? "" : "not ");
> * }
> *
> * if (!strcmp("end", action)) {
> @@ -286,7 +288,7 @@ static inline unsigned int hashmap_get_size(struct hashmap *map)
> * If an entry with matching hash code is found, `key` and `keydata` are passed
> * to `hashmap_cmp_fn` to decide whether the entry matches the key.
> */
> -void *hashmap_get(const struct hashmap *map, const void *key,
> +void *hashmap_get(const struct hashmap *map, const struct hashmap_entry *key,
> const void *keydata);super-nit: the whitespace before the second line is "\t\t\t " but should be "\t\t ".
(I'm really struggling to find things wrong with this series. Am I not reading it correctly, or is it just that good?)
Thanks, -Stolee