[ndnSIM] Ways to create new Interest object

Junxiao Shi shijunxiao at email.arizona.edu
Tue Apr 3 17:35:15 PDT 2018

Hi Mudasir

> *Method #2:* Creating Interest from an existing Interest like this:
> const Name& tempName = "---";
> Interest tempInterest = Interest(interest.wireEncode());
> tempInterest.setName(tempName);
> *My problem:*
> Now, I know Method#2 is the official way that meets my requirements. But
> the thing is, when I use method#2 it gives error on *findOrInsert* method
> in *pit.cpp* file and I don't understand its reason.
> auto entry = make_shared<Entry>(interest);

In certain contexts that use Interest::shared_from_this(), Interest must be
created using `make_shared`. Otherwise, .shared_from_this() will trigger
undefined behavior.

PIT is one of those contexts. So are many other places in NFD.
Thus, you need:
auto tempInterest = std::make_shared<Interest>(interest.wireEncode());

Yours, Junxiao
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20180403/68a75a8c/attachment.html>

More information about the ndnSIM mailing list