From 73531e9e48dccbc76cb7ae05b46b56a8a14bd8b0 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sun, 5 May 2013 16:10:13 -0400 Subject: [PATCH] ck_hs: Add ck_hs_reset_size operation. The ck_hs_reset_size operation takes an additional argument that allows the user to specify the size of the new generation of the hashset. --- include/ck_hs.h | 1 + src/ck_hs.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/ck_hs.h b/include/ck_hs.h index 07db610..dac5dc4 100644 --- a/include/ck_hs.h +++ b/include/ck_hs.h @@ -98,6 +98,7 @@ void *ck_hs_remove(ck_hs_t *, unsigned long, const void *); bool ck_hs_grow(ck_hs_t *, unsigned long); unsigned long ck_hs_count(ck_hs_t *); bool ck_hs_reset(ck_hs_t *); +bool ck_hs_reset_size(ck_hs_t *, unsigned long); void ck_hs_stat(ck_hs_t *, struct ck_hs_stat *); #endif /* _CK_HS_H */ diff --git a/src/ck_hs.c b/src/ck_hs.c index fb6e0e4..6c082e9 100644 --- a/src/ck_hs.c +++ b/src/ck_hs.c @@ -167,12 +167,12 @@ ck_hs_map_create(struct ck_hs *hs, unsigned long entries) } bool -ck_hs_reset(struct ck_hs *hs) +ck_hs_reset_size(struct ck_hs *hs, unsigned long capacity) { struct ck_hs_map *map, *previous; previous = hs->map; - map = ck_hs_map_create(hs, previous->capacity); + map = ck_hs_map_create(hs, capacity); if (map == NULL) return false; @@ -181,6 +181,15 @@ ck_hs_reset(struct ck_hs *hs) return true; } +bool +ck_hs_reset(struct ck_hs *hs) +{ + struct ck_hs_map *previous; + + previous = hs->map; + return ck_hs_reset_size(hs, previous->capacity); +} + static inline unsigned long ck_hs_map_probe_next(struct ck_hs_map *map, unsigned long offset,