No. tvb_get_ptr() returns a pointer pointing to the data inside the tvbuff, so
it is the tvbuff's
responsibility for freeing it. It's not explicitly stated in the comments, but
it's somewhat implied. I'll
explicitly state it for future reference.
/* WARNING! This function is possibly expensive, temporarily allocating
* another copy of the packet data. Furthermore, it's dangerous because once
* this pointer is given to the user, there's no guarantee that the user will
* honor the 'length' and not overstep the boundaries of the buffer.
*
* Return a pointer into our buffer if the data asked for via 'offset'/'length'
* is contiguous (which might not be the case for TVBUFF_COMPOSITE). If the
* data is not contiguous, a tvb_memdup() is called for the entire buffer
* and the pointer to the newly-contiguous data is returned. This dynamically-
* allocated memory will be freed when the tvbuff is freed, after the
* tvbuff_free_cb_t() is called, if any. */
guint8* tvb_get_ptr(tvbuff_t*, gint offset, gint length);
--gilbert
andreas.sikkema@xxxxxxxxxxx on 08/17/2000 08:47:12 AM
To: ethereal-dev@xxxxxxxx
cc: (bcc: Gilbert Ramirez/Tivoli Systems)
Subject: [ethereal-dev] Question about tvb_get_ptr()
Hi
Do I need to free() the pointer returned by tvb_get_ptr()?
Sometimes I get very confused about pointers....
--
Andreas Sikkema
andreas.sikkema@xxxxxxxxxxx
"Standing barefoot in a river of clues, most people would
not get their toes wet." - Brian Kantor in a.s.r.