Change types in a hashtable to allow template reuse

This commit is contained in:
Ludvig Strigeus 2018-11-17 19:09:16 +01:00
parent 4d3c9d6643
commit b52d8f3d70
2 changed files with 4 additions and 4 deletions

View file

@ -281,7 +281,7 @@ WgKeypair *WgDevice::LookupKeypairInAddrEntryMap(const IpAddr &addr, uint32 slot
auto it = addr_entry_lookup_.find(addr_x);
if (it == addr_entry_lookup_.end())
return NULL;
WgAddrEntry *addr_entry = it->second;
WgAddrEntry *addr_entry = (WgAddrEntry*)it->second;
return addr_entry->keys[slot];
}
@ -300,7 +300,7 @@ void WgDevice::UpdateKeypairAddrEntry_Locked(const IpAddr &addr, WgKeypair *keyp
if (keypair->addr_entry != NULL)
EraseKeypairAddrEntry_Locked(keypair);
WgAddrEntry **aep = &addr_entry_lookup_[addr_x], *ae;
WgAddrEntry **aep = (WgAddrEntry**)&addr_entry_lookup_[addr_x], *ae;
if ((ae = *aep) == NULL) {
*aep = ae = new WgAddrEntry(addr_x);

View file

@ -409,8 +409,8 @@ private:
WG_HASHTABLE_IMPL<uint32, std::pair<WgPeer*, WgKeypair*>, KeyIdHasher> key_id_lookup_;
// Mapping from IPV4 IP/PORT to WgPeer*, so we can find the peer when a key id is
// not explicitly included.
WG_HASHTABLE_IMPL<WgAddrEntry::IpPort, WgAddrEntry*, WgAddrEntry::IpPortHasher> addr_entry_lookup_;
// not explicitly included. Use void* here so we can reuse the same template instance.
WG_HASHTABLE_IMPL<WgAddrEntry::IpPort, void*, WgAddrEntry::IpPortHasher> addr_entry_lookup_;
WG_DECLARE_RWLOCK(addr_entry_lookup_lock_);
// Mapping from peer id to peer. This may be accessed only from MT.