Skip to content

Commit

Permalink
Fix unordered_multimap key_iter constructor to handle nullptr
Browse files Browse the repository at this point in the history
  • Loading branch information
KredeGC committed Dec 13, 2022
1 parent c76d5d6 commit 3accedb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions include/ktl/containers/unordered_multimap.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ namespace ktl
using reference = std::pair<K, V>&;

public:
key_iter() :
m_Key{},
m_Begin(nullptr),
m_Current(nullptr),
m_Counter(0),
m_SizeMask(0) {}

explicit key_iter(pair* current, pair* begin, size_t mask) :
m_Key(current->Key),
m_Begin(begin),
Expand Down Expand Up @@ -420,15 +427,15 @@ namespace ktl
key_iterator find(const K& index) const noexcept
{
if (m_Begin == nullptr)
return key_iterator(nullptr, nullptr, 0);
return key_iterator();

pair* block = get_pair(index, m_Begin, m_Mask);

// If occupied and not dead
if (block != m_End && flag_occupied_alive(block->Flags))
return key_iterator(block, m_Begin, m_Mask);

return key_iterator(nullptr, m_Begin, m_Mask);
return key_iterator();
}

void clear() noexcept
Expand Down

0 comments on commit 3accedb

Please sign in to comment.