Changing Closure API. No need for so many pointers...
diff --git a/ccnx/ccnx-closure.cpp b/ccnx/ccnx-closure.cpp
index bc9b244..a96bbbe 100644
--- a/ccnx/ccnx-closure.cpp
+++ b/ccnx/ccnx-closure.cpp
@@ -1,54 +1,63 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2013 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
+ *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
 #include "ccnx-closure.h"
 
 namespace Ccnx {
 
 Closure::Closure(const DataCallback &dataCallback, const TimeoutCallback &timeoutCallback)
-              : m_timeoutCallback(NULL), m_dataCallback(NULL)
+  : m_timeoutCallback (timeoutCallback)
+  , m_dataCallback (dataCallback)
 {
-  m_timeoutCallback = new TimeoutCallback (timeoutCallback);
-  m_dataCallback = new DataCallback (dataCallback);
-}
-
-Closure::Closure(const Closure &other)
-            : m_timeoutCallback(NULL), m_dataCallback(NULL)
-{
-  m_timeoutCallback = new TimeoutCallback(*(other.m_timeoutCallback));
-  m_dataCallback = new DataCallback(*(other.m_dataCallback));
 }
 
 Closure::~Closure ()
 {
-  delete m_dataCallback;
-  delete m_timeoutCallback;
-  m_dataCallback = NULL;
-  m_timeoutCallback = NULL;
 }
 
 Closure::TimeoutCallbackReturnValue
 Closure::runTimeoutCallback(const Name &interest)
 {
-  if ((*m_timeoutCallback).empty())
-  {
-    return RESULT_OK;
-  }
+  if (m_timeoutCallback.empty ())
+    {
+      return RESULT_OK;
+    }
 
-  return (*m_timeoutCallback)(interest);
+  return m_timeoutCallback (interest);
 }
 
 
 void
 Closure::runDataCallback(const Name &name, const Bytes &content)
 {
-  if (m_dataCallback != NULL) {
-    (*m_dataCallback)(name, content);
-  }
+  if (!m_dataCallback.empty ())
+    {
+      m_dataCallback (name, content);
+    }
 }
 
 Closure *
-Closure::dup() const
+Closure::dup () const
 {
-  Closure *closure = new Closure(*this);
-  return closure;
+  return new Closure (*this);
 }
 
 } // Ccnx
diff --git a/ccnx/ccnx-closure.h b/ccnx/ccnx-closure.h
index 1bcaa06..39fbc16 100644
--- a/ccnx/ccnx-closure.h
+++ b/ccnx/ccnx-closure.h
@@ -1,11 +1,30 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2013 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
+ *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
 #ifndef CCNX_CLOSURE_H
 #define CCNX_CLOSURE_H
 
 #include "ccnx-common.h"
 #include "ccnx-name.h"
 
-using namespace std;
-
 namespace Ccnx {
 
 class Closure
@@ -22,10 +41,11 @@
   typedef boost::function<TimeoutCallbackReturnValue (const Name &)> TimeoutCallback;
 
   Closure(const DataCallback &dataCallback, const TimeoutCallback &timeoutCallback = TimeoutCallback());
-  Closure(const Closure &other);
   virtual ~Closure();
+
   virtual void
   runDataCallback(const Name &name, const Bytes &content);
+
   virtual TimeoutCallbackReturnValue
   runTimeoutCallback(const Name &interest);
 
@@ -33,8 +53,8 @@
   dup() const;
 
 protected:
-  TimeoutCallback *m_timeoutCallback;
-  DataCallback *m_dataCallback;
+  TimeoutCallback m_timeoutCallback;
+  DataCallback m_dataCallback;
 };
 
 } // Ccnx
diff --git a/ccnx/ccnx-tunnel.cpp b/ccnx/ccnx-tunnel.cpp
index 0808663..6bf117f 100644
--- a/ccnx/ccnx-tunnel.cpp
+++ b/ccnx/ccnx-tunnel.cpp
@@ -1,3 +1,24 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2013 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
+ *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
 #include "ccnx-tunnel.h"
 #include "ccnx-pco.h"
 
@@ -28,12 +49,13 @@
 }
 
 int
-CcnxTunnel::sendInterest (const Name &interest, const Closure *closure, const Selectors &selectors)
+CcnxTunnel::sendInterest (const Name &interest, const Closure &closure, const Selectors &selectors)
 {
   Name tunneledInterest = queryRoutableName(interest);
-  Closure *cp = new TunnelClosure(closure, this, interest);
-  CcnxWrapper::sendInterest(tunneledInterest, cp, selectors);
-  delete cp;
+
+  CcnxWrapper::sendInterest(tunneledInterest,
+                            TunnelClosure(closure, *this, interest),
+                            selectors);
 
   return 0;
 }
@@ -118,33 +140,30 @@
   m_rit.erase(prefix);
 }
 
-TunnelClosure::TunnelClosure(const DataCallback &dataCallback, CcnxTunnel *tunnel, const Name &originalInterest, const TimeoutCallback &timeoutCallback)
-                  : Closure(dataCallback, timeoutCallback)
-                  , m_tunnel(tunnel)
-                  , m_originalInterest(originalInterest)
+TunnelClosure::TunnelClosure(const DataCallback &dataCallback, CcnxTunnel &tunnel,
+                             const Name &originalInterest, const TimeoutCallback &timeoutCallback)
+  : Closure(dataCallback, timeoutCallback)
+  , m_tunnel(tunnel)
+  , m_originalInterest(originalInterest)
 {
 }
 
-TunnelClosure::TunnelClosure(const Closure *closure, CcnxTunnel *tunnel, const Name &originalInterest)
-                 : Closure(*closure)
-                 , m_tunnel(tunnel)
+TunnelClosure::TunnelClosure(const Closure &closure, CcnxTunnel &tunnel, const Name &originalInterest)
+  : Closure(closure)
+  , m_tunnel(tunnel)
 {
 }
 
 Closure *
 TunnelClosure::dup() const
 {
-  Closure *closure = new TunnelClosure(*m_dataCallback, m_tunnel, m_originalInterest, *m_timeoutCallback);
-  return closure;
+  return new TunnelClosure (*this);
 }
 
 void
 TunnelClosure::runDataCallback(const Name &name, const Bytes &content)
 {
-  if (m_tunnel != NULL)
-  {
-    m_tunnel->handleTunneledData(name, content, (*m_dataCallback));
-  }
+  m_tunnel.handleTunneledData(name, content, m_dataCallback);
 }
 
 Closure::TimeoutCallbackReturnValue
diff --git a/ccnx/ccnx-tunnel.h b/ccnx/ccnx-tunnel.h
index 05f981a..ce56775 100644
--- a/ccnx/ccnx-tunnel.h
+++ b/ccnx/ccnx-tunnel.h
@@ -1,8 +1,27 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2013 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
+ *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
 #ifndef CCNX_TUNNEL_H
 #define CCNX_TUNNEL_H
 
-#include <boost/variant.hpp>
-
 #include "ccnx-common.h"
 #include "ccnx-wrapper.h"
 #include "ccnx-name.h"
@@ -16,8 +35,6 @@
 #endif // __GNUC__ version
 #endif // __GNUC__
 
-using namespace std;
-
 // Eventually, Sync::CcnxWrapper should be moved to this namespace.
 // It has nothing to do with Sync.
 namespace Ccnx
@@ -26,8 +43,8 @@
 class CcnxTunnel : public CcnxWrapper
 {
 public:
-  typedef multimap<Name, InterestCallback> RegisteredInterestTable;
-  typedef multimap<Name, InterestCallback>::iterator RitIter;
+  typedef std::multimap<Name, InterestCallback> RegisteredInterestTable;
+  typedef std::multimap<Name, InterestCallback>::iterator RitIter;
 
 
   CcnxTunnel();
@@ -41,7 +58,7 @@
   publishContentObject(const Name &name, const Bytes &contentObject, int freshness);
 
   virtual int
-  sendInterest (const Name &interest, const Closure *closure, const Selectors &selectors = Selectors());
+  sendInterest (const Name &interest, const Closure &closure, const Selectors &selectors = Selectors());
 
 
   // prefix is topology-independent
@@ -89,9 +106,10 @@
 class TunnelClosure : public Closure
 {
 public:
-  TunnelClosure(const DataCallback &dataCallback, CcnxTunnel *tunnel, const Name &originalInterest, const TimeoutCallback &timeoutCallback = TimeoutCallback());
+  TunnelClosure(const DataCallback &dataCallback, CcnxTunnel &tunnel,
+                const Name &originalInterest, const TimeoutCallback &timeoutCallback = TimeoutCallback());
 
-  TunnelClosure(const Closure *closure, CcnxTunnel *tunnel, const Name &originalInterest);
+  TunnelClosure(const Closure &closure, CcnxTunnel &tunnel, const Name &originalInterest);
 
   virtual void
   runDataCallback(const Name &name, const Bytes &content) _OVERRIDE;
@@ -100,10 +118,10 @@
   runTimeoutCallback(const Name &interest) _OVERRIDE;
 
   virtual Closure *
-  dup() const _OVERRIDE;
+  dup() const;
 
 private:
-  CcnxTunnel *m_tunnel;
+  CcnxTunnel &m_tunnel;
   Name m_originalInterest;
 };
 
diff --git a/ccnx/ccnx-wrapper.cpp b/ccnx/ccnx-wrapper.cpp
index b014a07..fcaf224 100644
--- a/ccnx/ccnx-wrapper.cpp
+++ b/ccnx/ccnx-wrapper.cpp
@@ -284,7 +284,7 @@
   return CCN_UPCALL_RESULT_OK;
 }
 
-int CcnxWrapper::sendInterest (const Name &interest, const Closure *closure, const Selectors &selectors)
+int CcnxWrapper::sendInterest (const Name &interest, const Closure &closure, const Selectors &selectors)
 {
   UniqueRecLock lock(m_mutex);
   if (!m_running || !m_connected)
@@ -294,7 +294,7 @@
   ccn_charbuf *pname = namePtr->getBuf();
   ccn_closure *dataClosure = new ccn_closure;
 
-  Closure *myClosure = closure->dup();
+  Closure *myClosure = closure.dup();
   dataClosure->data = (void *)myClosure;
 
   dataClosure->p = &incomingData;
diff --git a/ccnx/ccnx-wrapper.h b/ccnx/ccnx-wrapper.h
index baa22b1..2e66a2d 100644
--- a/ccnx/ccnx-wrapper.h
+++ b/ccnx/ccnx-wrapper.h
@@ -38,7 +38,7 @@
   clearInterestFilter (const Name &prefix);
 
   virtual int
-  sendInterest (const Name &interest, const Closure *closure, const Selectors &selector = Selectors());
+  sendInterest (const Name &interest, const Closure &closure, const Selectors &selector = Selectors());
 
   virtual int
   publishData (const Name &name, const unsigned char *buf, size_t len, int freshness);
diff --git a/src/fetch-manager.cc b/src/fetch-manager.cc
index 931d2c1..2b43c62 100644
--- a/src/fetch-manager.cc
+++ b/src/fetch-manager.cc
@@ -90,7 +90,7 @@
 }
 
 void
-FetchManager::NoDataTimeout (Fetcher &fetcher)
+FetchManager::DidNoDataTimeout (Fetcher &fetcher)
 {
   fetcher.m_forwardingHint = Ccnx::Name ("/ndn/broadcast");
   fetcher.m_active = false;
@@ -99,19 +99,18 @@
     m_currentParallelFetches --;
     // no need to do anything with the m_fetchList
   }
-  
+
   ScheduleFetches ();
 }
 
 void
-FetchManager::FetchComplete (Fetcher &fetcher)
+FetchManager::DidFetchComplete (Fetcher &fetcher)
 {
-  fetcher.m_active = false;
   {
     unique_lock<mutex> lock (m_parellelFetchMutex);
     m_currentParallelFetches --;
     m_fetchList.erase_and_dispose (FetchList::s_iterator_to (fetcher), fetcher_disposer ());
   }
-  
+
   // ? do something else
 }
diff --git a/src/fetch-manager.h b/src/fetch-manager.h
index b200318..73a0699 100644
--- a/src/fetch-manager.h
+++ b/src/fetch-manager.h
@@ -57,19 +57,19 @@
   inline SchedulerPtr
   GetScheduler ();
 
-private:
-  void
-  ScheduleFetches ();  
-  
   // Events called from Fetcher
   void
-  NoDataTimeout (Fetcher &fetcher);
+  DidNoDataTimeout (Fetcher &fetcher);
 
   void
-  FetchComplete (Fetcher &fetcher);
+  DidFetchComplete (Fetcher &fetcher);
 
 private:
-  
+  void
+  ScheduleFetches ();
+
+private:
+
 private:
   Ccnx::CcnxWrapperPtr m_ccnx;
   SyncLogPtr m_sync; // to access forwarding hints
@@ -83,7 +83,7 @@
   typedef boost::intrusive::member_hook< Fetcher,
                                          boost::intrusive::list_member_hook<>, &Fetcher::m_managerListHook> MemberOption;
   typedef boost::intrusive::list<Fetcher, MemberOption> FetchList;
-  
+
   FetchList m_fetchList;
 };
 
@@ -99,7 +99,7 @@
   return m_scheduler;
 }
 
-typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info_str; 
+typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info_str;
 namespace Error {
 struct FetchManager : virtual boost::exception, virtual std::exception { };
 }
diff --git a/src/fetcher.cc b/src/fetcher.cc
index c015407..6745518 100644
--- a/src/fetcher.cc
+++ b/src/fetcher.cc
@@ -20,6 +20,8 @@
  */
 
 #include "fetcher.h"
+#include "fetch-manager.h"
+
 #include <boost/make_shared.hpp>
 #include <boost/ref.hpp>
 #include <boost/throw_exception.hpp>
@@ -52,3 +54,19 @@
 {
   m_active = true;
 }
+
+void
+Fetcher::OnData (uint32_t seqno, const Ccnx::Name &name, const Ccnx::Bytes &)
+{
+  // bla bla
+  if (0)
+    {
+      m_active = false;
+      m_fetchManager.DidFetchComplete (*this);
+    }
+}
+
+void
+Fetcher::OnTimeout (uint32_t seqno, const Ccnx::Name &name)
+{
+}
diff --git a/src/fetcher.h b/src/fetcher.h
index 5cb3977..c6bc883 100644
--- a/src/fetcher.h
+++ b/src/fetcher.h
@@ -23,6 +23,8 @@
 #define FETCHER_H
 
 #include "ccnx-wrapper.h"
+#include "ccnx-name.h"
+
 #include "scheduler.h"
 #include <boost/intrusive/list.hpp>
 
@@ -39,20 +41,20 @@
 private:
   void
   RestartPipeline ();
-  
-  void
-  OnData ();
 
   void
-  OnTimeout ();
-  
+  OnData (uint32_t seqno, const Ccnx::Name &name, const Ccnx::Bytes &);
+
+  void
+  OnTimeout (uint32_t seqno, const Ccnx::Name &name);
+
 private:
   FetchManager &m_fetchManager;
   bool m_active;
-  
+
   Ccnx::Name m_name;
   Ccnx::Name m_forwardingHint;
-  
+
   int32_t m_minSendSeqNo;
   int32_t m_maxSendSeqNo;
   int32_t m_minSeqNo;
@@ -60,11 +62,14 @@
 
   uint32_t m_pipeline;
 
-  boost::intrusive::list_member_hook<> m_managerListHook;  
+  // Ccnx::Closure m_onDataClosure;
+  // Ccnx::Closure m_onTimeoutClosure;
+
+  boost::intrusive::list_member_hook<> m_managerListHook;
   friend class FetchManager;
 };
 
-typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info_str; 
+typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info_str;
 
 namespace Error {
 struct Fetcher : virtual boost::exception, virtual std::exception { };
diff --git a/src/sync-core.cc b/src/sync-core.cc
index 1e9a947..4ddf47f 100644
--- a/src/sync-core.cc
+++ b/src/sync-core.cc
@@ -64,11 +64,14 @@
          , m_localPrefix(localPrefix)
          , m_syncPrefix(syncPrefix)
          , m_handle(handle)
+         , m_syncClosure (boost::bind(&SyncCore::handleSyncData, this, _1, _2),
+                          boost::bind(&SyncCore::handleSyncInterestTimeout, this, _1))
+         , m_recoverClosure (boost::bind(&SyncCore::handleRecoverData, this, _1, _2),
+                             boost::bind(&SyncCore::handleRecoverInterestTimeout, this, _1))
          , m_recoverWaitGenerator(new RandomIntervalGenerator(WAIT, RANDOM_PERCENT, RandomIntervalGenerator::UP))
 {
   m_rootHash = m_log->RememberStateInStateLog();
-  m_syncClosure = new Closure(boost::bind(&SyncCore::handleSyncData, this, _1, _2), boost::bind(&SyncCore::handleSyncInterestTimeout, this, _1));
-  m_recoverClosure = new Closure(boost::bind(&SyncCore::handleRecoverData, this, _1, _2), boost::bind(&SyncCore::handleRecoverInterestTimeout, this, _1));
+
   m_handle->setInterestFilter(m_syncPrefix, boost::bind(&SyncCore::handleInterest, this, _1));
   m_log->initYP(m_yp);
   m_scheduler->start();
@@ -77,17 +80,7 @@
 
 SyncCore::~SyncCore()
 {
-  if (m_syncClosure != 0)
-  {
-    delete m_syncClosure;
-    m_syncClosure = 0;
-  }
-
-  if (m_recoverClosure != 0)
-  {
-    delete m_recoverClosure;
-    m_recoverClosure = 0;
-  }
+  // need to "deregister" closures
 }
 
 Name
diff --git a/src/sync-core.h b/src/sync-core.h
index d6dbd32..cb44398 100644
--- a/src/sync-core.h
+++ b/src/sync-core.h
@@ -126,8 +126,8 @@
   YellowPage m_yp;
   Mutex m_ypMutex;
   CcnxWrapperPtr m_handle;
-  Closure *m_syncClosure;
-  Closure *m_recoverClosure;
+  Closure m_syncClosure;
+  Closure m_recoverClosure;
 
   IntervalGeneratorPtr m_recoverWaitGenerator;
 
diff --git a/test/test-ccnx-tunnel.cc b/test/test-ccnx-tunnel.cc
index 6c2ab0d..724d6e5 100644
--- a/test/test-ccnx-tunnel.cc
+++ b/test/test-ccnx-tunnel.cc
@@ -82,21 +82,16 @@
   g_dc_o = 0;
   t1->publishData(Name(inner), (const unsigned char *)inner.c_str(), inner.size(), 5);
   usleep(100000);
-  Closure *outerClosure = new Closure(bind(outerCallback, _1, _2));
-  c1->sendInterest(Name("/local/hello"), outerClosure);
+
+  c1->sendInterest(Name("/local/hello"), Closure(bind(outerCallback, _1, _2)));
   usleep(100000);
   // it is indeed published as /local/hello
   BOOST_CHECK_EQUAL(g_dc_o, 1);
 
   g_dc_i = 0;
-  Closure *innerClosure = new Closure(bind(innerCallback, _1, _2));
-  t2->sendInterest(Name(inner), innerClosure);
+  t2->sendInterest(Name(inner), Closure(bind(innerCallback, _1, _2)));
   usleep(100000);
   BOOST_CHECK_EQUAL(g_dc_i, 1);
-
-  delete outerClosure;
-  delete innerClosure;
-
 }
 
 BOOST_AUTO_TEST_CASE (CcnxTunnelRegister)
@@ -107,7 +102,7 @@
   t3.overridePrefix();
   t3.setInterestFilter(Name("/t3"), bind(interestCallback, _1));
   usleep(100000);
-  Closure *innerClosure = new Closure(bind(innerCallback, _1, _2));
+  Closure innerClosure (bind(innerCallback, _1, _2));
   t1->sendInterest(Name("/t3/hello"), innerClosure);
   usleep(100000);
   BOOST_CHECK_EQUAL(g_dc_i, 1);
@@ -119,7 +114,6 @@
   usleep(100000);
   BOOST_CHECK_EQUAL(g_dc_i, 1);
   BOOST_CHECK_EQUAL(g_ic, 1);
-  delete innerClosure;
 
 }
 
diff --git a/test/test-ccnx-wrapper.cc b/test/test-ccnx-wrapper.cc
index 651692f..b64f513 100644
--- a/test/test-ccnx-wrapper.cc
+++ b/test/test-ccnx-wrapper.cc
@@ -53,7 +53,7 @@
   usleep(100000);
   c2->setInterestFilter(prefix2, bind(publish2, _1));
 
-  Closure *closure = new Closure(bind(dataCallback, _1, _2), bind(timeout, _1));
+  Closure closure (bind(dataCallback, _1, _2), bind(timeout, _1));
 
   c1->sendInterest(Name("/c2/hi"), closure);
   usleep(100000);
@@ -63,13 +63,12 @@
   // reset
   g_dataCallback_counter = 0;
   g_timeout_counter = 0;
-  delete closure;
 }
 
 BOOST_AUTO_TEST_CASE (CcnxWrapperSelector)
 {
 
-  Closure *closure = new Closure(bind(dataCallback, _1, _2), bind(timeout, _1));
+  Closure closure (bind(dataCallback, _1, _2), bind(timeout, _1));
 
   Selectors selectors;
   selectors.interestLifetime(1);
@@ -94,7 +93,6 @@
   // reset
   g_dataCallback_counter = 0;
   g_timeout_counter = 0;
-  delete closure;
 }
 
 BOOST_AUTO_TEST_SUITE_END()