mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 17:18:20 +00:00
Improve TableVal HashKey management
* Deprecated ComputeHash() methods and replaced with MakeHashKey() which returns std::unique_ptr<HashKey> * Deprecated RecoverIndex() and replaced with RecreateIndex() which takes HashKey& and returns IntrusivePtr. * Updated the new TableVal Assign()/Remove() methods to take either std::unique_ptr<HashKey> or HashKey& as appropriate for clarity of ownership expectations.
This commit is contained in:
parent
8a6a92c348
commit
3f92df51b7
18 changed files with 137 additions and 114 deletions
|
@ -53,8 +53,11 @@ IPAddr::IPAddr(const BroString& s)
|
|||
}
|
||||
|
||||
HashKey* IPAddr::GetHashKey() const
|
||||
{ return MakeHashKey().release(); }
|
||||
|
||||
std::unique_ptr<HashKey> IPAddr::MakeHashKey() const
|
||||
{
|
||||
return new HashKey((void*)in6.s6_addr, sizeof(in6.s6_addr));
|
||||
return std::make_unique<HashKey>((void*)in6.s6_addr, sizeof(in6.s6_addr));
|
||||
}
|
||||
|
||||
static inline uint32_t bit_mask32(int bottom_bits)
|
||||
|
@ -303,6 +306,9 @@ std::string IPPrefix::AsString() const
|
|||
}
|
||||
|
||||
HashKey* IPPrefix::GetHashKey() const
|
||||
{ return MakeHashKey().release(); }
|
||||
|
||||
std::unique_ptr<HashKey> IPPrefix::MakeHashKey() const
|
||||
{
|
||||
struct {
|
||||
in6_addr ip;
|
||||
|
@ -312,7 +318,7 @@ HashKey* IPPrefix::GetHashKey() const
|
|||
key.ip = prefix.in6;
|
||||
key.len = Length();
|
||||
|
||||
return new HashKey(&key, sizeof(key));
|
||||
return std::make_unique<HashKey>(&key, sizeof(key));
|
||||
}
|
||||
|
||||
bool IPPrefix::ConvertString(const char* text, IPPrefix* result)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue