In expressInterest, just take a pointer to the Closure, not a shared_ptr
diff --git a/ndn-cpp/face.cpp b/ndn-cpp/face.cpp
index eeaac00..c5be3d2 100644
--- a/ndn-cpp/face.cpp
+++ b/ndn-cpp/face.cpp
@@ -13,7 +13,7 @@
namespace ndn {
-void Face::expressInterest(const Name &name, const shared_ptr<Closure> &closure, const Interest *interestTemplate)
+void Face::expressInterest(const Name &name, Closure *closure, const Interest *interestTemplate)
{
Interest interest(name);
shared_ptr<vector<unsigned char> > encoding = interest.wireEncode();
diff --git a/ndn-cpp/face.hpp b/ndn-cpp/face.hpp
index a730161..c646dab 100644
--- a/ndn-cpp/face.hpp
+++ b/ndn-cpp/face.hpp
@@ -18,17 +18,17 @@
class Face : public ElementListener {
public:
Face(const char *host, unsigned short port, const ptr_lib::shared_ptr<Transport> &transport)
- : host_(host), port_(port), transport_(transport)
+ : host_(host), port_(port), transport_(transport), tempClosure_(0)
{
}
Face(const char *host, unsigned short port)
- : host_(host), port_(port), transport_(new UdpTransport())
+ : host_(host), port_(port), transport_(new UdpTransport()), tempClosure_(0)
{
}
Face(const char *host)
- : host_(host), port_(9695), transport_(new UdpTransport())
+ : host_(host), port_(9695), transport_(new UdpTransport()), tempClosure_(0)
{
}
@@ -38,12 +38,12 @@
* closure->upcall(UPCALL_DATA (or UPCALL_DATA_UNVERIFIED),
* UpcallInfo(this, interest, 0, data)).
* @param name reference to a Name for the interest. This does not keep a pointer to the Name object.
- * @param closure a shared_ptr for the Closure. This uses shared_ptr to take another reference to the object.
+ * @param closure a pointer for the Closure. The caller must manage the memory for the Closure. This will not try to delete it.
* @param interestTemplate if not 0, copy interest selectors from the template. This does not keep a pointer to the Interest object.
*/
- void expressInterest(const Name &name, const ptr_lib::shared_ptr<Closure> &closure, const Interest *interestTemplate);
+ void expressInterest(const Name &name, Closure *closure, const Interest *interestTemplate);
- void expressInterest(const Name &name, const ptr_lib::shared_ptr<Closure> &closure)
+ void expressInterest(const Name &name, Closure *closure)
{
expressInterest(name, closure, 0);
}
@@ -62,7 +62,7 @@
ptr_lib::shared_ptr<Transport> transport_;
string host_;
unsigned short port_;
- ptr_lib::shared_ptr<Closure> tempClosure_;
+ Closure *tempClosure_;
};
}
diff --git a/tests/test-get-async.cpp b/tests/test-get-async.cpp
index ab77a09..1acf65f 100644
--- a/tests/test-get-async.cpp
+++ b/tests/test-get-async.cpp
@@ -43,12 +43,12 @@
int main(int argc, char** argv)
{
try {
- shared_ptr<MyClosure> closure(new MyClosure());
+ MyClosure closure;
Face face("E.hub.ndn.ucla.edu", 9695, shared_ptr<UdpTransport>(new UdpTransport()));
- face.expressInterest(Name("/ndn/ucla.edu/apps/ndn-js-test/hello.txt/level2/%FD%05%0B%16%7D%95%0E"), closure);
+ face.expressInterest(Name("/ndn/ucla.edu/apps/ndn-js-test/hello.txt/level2/%FD%05%0B%16%7D%95%0E"), &closure);
// Pump the receive process. This should really be done by a socket listener.
- while (!closure->gotContent_)
+ while (!closure.gotContent_)
face.getTransport()->tempReceive();
} catch (std::exception &e) {
cout << "exception: " << e.what() << endl;