[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Destructor for a packet?
I think that if you really want variable-length data in a packet, it's
better to put them in the data_ areas in a Packet instead of creating a
new header and put a pointer there. The SRM agent may be an example
(srm.{h,cc}, srm-header.h).
- Haobo
On Mon, 19 Jul 1999, Daniel Friedman wrote:
> 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
>
>