diff --git a/include/ck_hs.h b/include/ck_hs.h index 4d0bc03..157c00c 100644 --- a/include/ck_hs.h +++ b/include/ck_hs.h @@ -88,6 +88,8 @@ typedef struct ck_hs_iterator ck_hs_iterator_t; void ck_hs_iterator_init(ck_hs_iterator_t *); bool ck_hs_next(ck_hs_t *, ck_hs_iterator_t *, void **); +bool ck_hs_move(ck_hs_t *, ck_hs_t *, ck_hs_hash_cb_t *, + ck_hs_compare_cb_t *, struct ck_malloc *); bool ck_hs_init(ck_hs_t *, unsigned int, ck_hs_hash_cb_t *, ck_hs_compare_cb_t *, struct ck_malloc *, unsigned long, unsigned long); void ck_hs_destroy(ck_hs_t *); diff --git a/src/ck_hs.c b/src/ck_hs.c index cac2505..597838c 100644 --- a/src/ck_hs.c +++ b/src/ck_hs.c @@ -582,6 +582,26 @@ ck_hs_remove(struct ck_hs *hs, return object; } +bool +ck_hs_move(struct ck_hs *hs, + struct ck_hs *source, + ck_hs_hash_cb_t *hf, + ck_hs_compare_cb_t *compare, + struct ck_malloc *m) +{ + + if (m == NULL || m->malloc == NULL || m->free == NULL || hf == NULL) + return false; + + hs->mode = source->mode; + hs->seed = source->seed; + hs->map = source->map; + hs->m = m; + hs->hf = hf; + hs->compare = compare; + return true; +} + bool ck_hs_init(struct ck_hs *hs, unsigned int mode,