]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2100] (not directly related) cleanup: always destroy old data in setData().
authorJINMEI Tatuya <jinmei@isc.org>
Thu, 9 Aug 2012 00:56:16 +0000 (17:56 -0700)
committerJINMEI Tatuya <jinmei@isc.org>
Thu, 9 Aug 2012 00:56:16 +0000 (17:56 -0700)
actually the previous implementation seems buggy; it returns the given pionter,
not the old data.  Worse, this code path isn't tested.  It's a typical example
of YAGNI; if we don't see the need for it, don't do it; if you cannot regist
the temptation of making it smarter, at least you should write tests.

At least ZoneTable doesn't need it, so I chose to clean it up.  If and when
we find it necessary, we should implementation from the scratch, and
test-driven.

src/lib/datasrc/memory/domaintree.h

index cca348cf72a27eee777b70a4025c8166c1c2ae8a..33efc880826fff41f95fd7a669cc805f9389f261 100644 (file)
@@ -245,19 +245,15 @@ public:
     /// \name Setter functions.
     //@{
 
-    /// \brief Set the data stored in the node. If there is old data, it
-    /// is either returned or destroyed based on what is passed in \c
-    /// old_data.
+    /// \brief Set the data stored in the node.
+    ///
+    /// Any old data is destroyed.
+    ///
     /// \param mem_sgmt The \c MemorySegment that allocated memory for
     ///                 the node data.
     /// \param data The new data to set.
-    /// \param old_data If \c NULL is passed here, any old data is
-    ///                 destroyed. Otherwise, the old data is returned
-    ///                 in this location.
-    void setData(util::MemorySegment& mem_sgmt, T* data, T** old_data = NULL) {
-        if (old_data != NULL) {
-            *old_data = data;
-        } else {
+    void setData(util::MemorySegment& mem_sgmt, T* data) {
+        if (data_) {
             const DT deleter;
             deleter(mem_sgmt, data_.get());
         }