[Ns-bugs] [Bug 273] method arguments of type Ptr<Packet> are way too fragile in public API

bugzilla-daemon@nsnam-www.ece.gatech.edu bugzilla-daemon at nsnam-www.ece.gatech.edu
Sun Aug 10 10:54:48 PDT 2008


http://www.nsnam.org/bugzilla/show_bug.cgi?id=273





------- Comment #5 from craigdo at ee.washington.edu  2008-08-10 13:54 -------
I have a really hard time with this one since it is such a basic conceptual
thing that you don't pass a pointer to multiple consumers if you don't want
them both modifying the packet.  I also have a hard time with passing a const
packet to a method that will almost certainly change it in order to make life
easier in the calling method.

Unfortunately, it seems that in practice it is just too easy to make this
mistake.  One of the things I keep saying to myself is, "if we can't get it
right, what hope is there for some poor Joe who doesn't work with our code all
the time."  

We addressed the memory management aspects of this and similar situations, but
there are other semantic issues remaing that are hidden here.  It seems that
making the API pass const packets will put up a firewall that will prevent this
kind of thing in the future at the costs of looking a little strange and
introducing possibly unnecessary packet copies.

So I am reluctantly forced to agree with Mathieu at this point.  Up and down
const packets and take the performance hit of the copy to avoid programming
errors; and if that is a problem, optimize the copy.

I can't believe I wrote that ...


-- 
Configure bugmail: http://www.nsnam.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.


More information about the Ns-bugs mailing list