Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/hashtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ void hashtableSetResizePolicy(hashtableResizePolicy policy) {
#define ENTRIES_PER_BUCKET 7
#define BUCKET_BITS_TYPE uint8_t
#define BITS_NEEDED_TO_STORE_POS_WITHIN_BUCKET 3
/* Iterator table value indicating iteration is complete */
#define HASHTABLE_ITER_END_TABLE 2
Comment thread
uriyage marked this conversation as resolved.
Outdated

/* Selecting the number of buckets.
*
Expand Down Expand Up @@ -2025,6 +2027,12 @@ void hashtableReleaseIterator(hashtableIterator *iterator) {
* Returns false if there are no more entries. */
bool hashtableNext(hashtableIterator *iterator, void **elemptr) {
iter *iter = iteratorFromOpaque(iterator);

assert(iter->table <= HASHTABLE_ITER_END_TABLE);
if (iter->table == HASHTABLE_ITER_END_TABLE) {
return false;
}

while (1) {
if (iter->index == -1 && iter->table == 0) {
/* It's the first call to next. */
Expand Down Expand Up @@ -2102,6 +2110,7 @@ bool hashtableNext(hashtableIterator *iterator, void **elemptr) {
}
return true;
}
iter->table = HASHTABLE_ITER_END_TABLE;
return false;
}

Expand Down
Loading