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.
ck_pring
Samy Al Bahra 12 years ago
parent 327c0fdc95
commit 73531e9e48

@ -98,6 +98,7 @@ void *ck_hs_remove(ck_hs_t *, unsigned long, const void *);
bool ck_hs_grow(ck_hs_t *, unsigned long); bool ck_hs_grow(ck_hs_t *, unsigned long);
unsigned long ck_hs_count(ck_hs_t *); unsigned long ck_hs_count(ck_hs_t *);
bool ck_hs_reset(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 *); void ck_hs_stat(ck_hs_t *, struct ck_hs_stat *);
#endif /* _CK_HS_H */ #endif /* _CK_HS_H */

@ -167,12 +167,12 @@ ck_hs_map_create(struct ck_hs *hs, unsigned long entries)
} }
bool 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; struct ck_hs_map *map, *previous;
previous = hs->map; previous = hs->map;
map = ck_hs_map_create(hs, previous->capacity); map = ck_hs_map_create(hs, capacity);
if (map == NULL) if (map == NULL)
return false; return false;
@ -181,6 +181,15 @@ ck_hs_reset(struct ck_hs *hs)
return true; 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 static inline unsigned long
ck_hs_map_probe_next(struct ck_hs_map *map, ck_hs_map_probe_next(struct ck_hs_map *map,
unsigned long offset, unsigned long offset,

Loading…
Cancel
Save