Closed cxm1997 closed 1 month ago
use master code to test
test code at https://gist.github.com/cxm1997/06f99190be5e553f5b476286f333ad14
run result: S0 0 S1 100000 S2 100000 S3 48739 continue 100000 remove 51261
Thanks! The fix is in 1ab7aec75fdb3e65e11aefbd6ea017e7dcdcd8bf I also added a test which was reproducing the issue before fixing the code in hashtable.c
ht_create(65536, 65536, NULL);
TEST_1 remove all item: add 100000 item to hashtable, before ht_foreach_value, ht_count() is 100000 then ht_foreach_value. in callback function return HT_ITERATOR_REMOVE, record entry callback function count is 51261 after, ht_count() is 48739
TEST_2 contine all item: add 100000 item to hashtable, before ht_foreach_value, ht_count() is 100000 then ht_foreach_value, in callback function return HT_ITERATOR_CONTINUE, record entry callback function count is 100000 after, ht_count() is 100000
actually, I want to traverse all items and delete them so, when ht_foreach_value callback return HT_ITERATOR_REMOVE, will lose item.