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

Wireshark-dev: Re: [Wireshark-dev] Adding Buffer Stream View

From: didier <dgautheron@xxxxxxxx>
Date: Wed, 22 Apr 2009 20:58:27 +0200
Hi,
Le mercredi 22 avril 2009 ᅵ 18:34 +0000, gogrady@xxxxxxxxx a ᅵcrit :
> Thank you both you and Jeff, this is exactly what i was looking for. However, run into a bit of a problem. The buffer that i create, is returned from a dll where i allocate and free the memory from. I put wrapper type of functions in my wireshark dissector that frees the memory after each packet. I ended up with fe ee fe ee fe ee (etc) as my buffer which means it is freed memory. I was wondering if there is a place to put my free memory call, or if there is a way to kind of copy data over to the dissector, free my dll memory, and have wireshark then be incharge of freeing the memory it allocated. I hope you understand what my situation is. 
> 
add a call to tvb_set_free_cb()
after tvb_new_read_data()

next_tvb = tvb_new_real_data(data, datalen, datalen);
tvb_set_free_cb(new_tvb, my_free);

my_free() is called when next_tvb is freed.

for example if data is a g_malloc buffer, g_free will do it.

Didier