[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Destructor for a packet?
I have created a packet header which looks something like this:
struct hdr_mypkt {
// ...
char *mydata;
// ...
}
...and I dynamically allocate memory (using "new") for "mydata" to point
to. (This way I can change the length of a field in the packet.) The
problem I have is that if I send such a packet through a link, and this
packet overflows in the queue of the link, [it at least seems that] the
memory dynamically allocated earlier is not freed.
Hence I think I need something like a destructor for this packet, which
will free the memory. But how does one make a destructor, since custom
packet types are not themselves classes in NS?
Or, if my approach is incorrect--either 1) in making a variable-length
packet field, or in 2) freeing the memory of a dynamically-allocated
field if the packet is dropped by queue overflow--, what should I be
doing?
Many thanks for all suggestions!!
--daniel
---------------------------------------------------------------------------
Daniel Friedman [email protected] http://www.isr.umd.edu/~danielf