diff --git a/src/Val.cc b/src/Val.cc index 7bccc6e0b0..8d93426721 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -1563,12 +1563,10 @@ void TableVal::Init(TableTypePtr t, bool ordered) { def_val = nullptr; if ( table_type->IsSubNetIndex() ) - subnets = new detail::PrefixTable; - else - subnets = nullptr; + subnets = std::make_unique(); if ( table_type->IsPatternIndex() ) - pattern_matcher = new detail::TablePatternMatcher(this, table_type->Yield()); + pattern_matcher = std::make_unique(this, table_type->Yield()); table_hash = new detail::CompositeHash(table_type->GetIndices()); if ( ordered ) @@ -1585,8 +1583,6 @@ TableVal::~TableVal() { delete table_hash; delete table_val; - delete subnets; - delete pattern_matcher; delete expire_iterator; } diff --git a/src/Val.h b/src/Val.h index 987b2081eb..96bc5a037a 100644 --- a/src/Val.h +++ b/src/Val.h @@ -939,7 +939,8 @@ public: // Returns the Prefix table used inside the table (if present). // This allows us to do more direct queries to this specialized // type that the general Table API does not allow. - const detail::PrefixTable* Subnets() const { return subnets; } + const detail::PrefixTable* Subnets() const { return subnets.get(); } + void Describe(ODesc* d) const override; @@ -1048,8 +1049,8 @@ protected: detail::ExprPtr expire_func; TableValTimer* timer; RobustDictIterator* expire_iterator; - detail::PrefixTable* subnets; - detail::TablePatternMatcher* pattern_matcher = nullptr; + std::unique_ptr subnets; + std::unique_ptr pattern_matcher; ValPtr def_val; detail::ExprPtr change_func; std::string broker_store;