fib: implicitly delete empty Entry
Fib::removeNextHopFromAllEntries automatically deletes fib::Entry
if the last nexthop record is being removed.
refs #1341
Change-Id: I36d42fe8f9fc8f03d194f845020aff408cd70488
diff --git a/daemon/table/name-tree.hpp b/daemon/table/name-tree.hpp
index 1a30b2b..3d0de70 100644
--- a/daemon/table/name-tree.hpp
+++ b/daemon/table/name-tree.hpp
@@ -100,6 +100,9 @@
shared_ptr<name_tree::Entry>
findExactMatch(const Name& prefix) const;
+ shared_ptr<name_tree::Entry>
+ findExactMatch(const fib::Entry& fibEntry) const;
+
/**
* \brief Erase a Name Tree Entry if this entry is empty.
* \details If a Name Tree Entry contains no Children, no FIB, no PIT, and
@@ -143,7 +146,8 @@
*/
const_iterator
partialEnumerate(const Name& prefix,
- const name_tree::EntrySubTreeSelector& entrySubTreeSelector = name_tree::AnyEntrySubTree()) const;
+ const name_tree::EntrySubTreeSelector& entrySubTreeSelector =
+ name_tree::AnyEntrySubTree()) const;
/**
* \brief Enumerate all the name prefixes that satisfy the prefix and entrySelector
@@ -203,13 +207,13 @@
operator!=(const const_iterator& other) const;
private:
- bool m_shouldVisitChildren;
const NameTree& m_nameTree;
shared_ptr<name_tree::Entry> m_entry;
shared_ptr<name_tree::Entry> m_subTreeRoot;
shared_ptr<name_tree::EntrySelector> m_entrySelector;
shared_ptr<name_tree::EntrySubTreeSelector> m_entrySubTreeSelector;
NameTree::IteratorType m_type;
+ bool m_shouldVisitChildren;
};
private:
@@ -250,6 +254,12 @@
return m_nBuckets;
}
+inline shared_ptr<name_tree::Entry>
+NameTree::findExactMatch(const fib::Entry& fibEntry) const
+{
+ return fibEntry.m_nameTreeEntry;
+}
+
inline NameTree::const_iterator
NameTree::begin() const
{