Re: [PATCH] hashmap: add API to disable item counting when threaded
- From
Simon Ruderich <simon@ruderich.org>
- Date
- Sep 2, 2017, 08:39 UTC
- Message-ID
- <20170902083920.simgdrdteorxt6yo@ruderich.org>
- In-Reply-To
- <20170830185922.10107-2-git@jeffhostetler.com>
On Wed, Aug 30, 2017 at 06:59:22PM +0000, Jeff Hostetler wrote:
> [snip] > +/* > + * Re-enable item couting when adding/removing items. > + * If counting is currently disabled, it will force count them.
The code always recounts them. Either the comment or the code should be adjusted.
Show 15 quoted lines
> + * This might be used after leaving a threaded section.
> + */
> +static inline void hashmap_enable_item_counting(struct hashmap *map)
> +{
> + void *item;
> + unsigned int n = 0;
> + struct hashmap_iter iter;
> +
> + hashmap_iter_init(map, &iter);
> + while ((item = hashmap_iter_next(&iter)))
> + n++;
> +
> + map->do_count_items = 1;
> + map->private_size = n;
> +}Regards Simon
-- + privacy is necessary + using gnupg http://gnupg.org + public key id: 0x92FEFDB7E44C32F9