Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Ethereal-dev: RE: [Ethereal-dev] Create new tvbuff

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Jeff Foster <jfoste@xxxxxxxxxxxx>
Date: Sat, 31 Mar 2001 10:52:37 -0600
From: Guy Harris [mailto:guy@xxxxxxxxxx]
Sent: Friday, March 30, 2001 4:49 PM

> >         TRY {		/* create the new tvbuffer with your data */
> >                 tvb = tvb_new_real_data( data, len, len, "DataName");
> > 		
> >         }
> >         CATCH(BoundsError) {
> >                 g_assert_not_reached();
> > 		g_free(buf);
> > 		return NULL;
> >         }
> >         CATCH(ReportedBoundsError) {
> >  		g_free(buf);
> >                return NULL;
> >         }
> 
> Note that the only exception "tvb_new_real_data()" throws is
> ReportedBoundsError, and it only throws that if you pass in -1 as the
> third argument, which you shouldn't be doing - you should be specifying
> how much data there would have been if the entire packet had been
> captured or, if that information isn't available, specifying how much
> data there is (i.e., third argument being the same as the second
> argument).

Should we wrap all of this in a function to create the tvfbuff and 
do the linking need.  Something like -

tvbuff_t*
new_data_tvbuffer( tvbuff_t *parent_tvb, 
			gchar *name,
			guint8 *data,
			guint len,
			tvbuff_free_cb_t free_callback);

This function should allow a NULL value for free_callback.

Where do we put it?


Jeff Foster
jfoste@xxxxxxxxxxxx