Wireshark-dev: Re: [Wireshark-dev] Freeing memory of se_alloc'ated object
From: Guy Harris <[email protected]>
Date: Sun, 1 May 2011 11:40:35 -0700
On May 1, 2011, at 4:51 AM, Max wrote:

> I'm writing a dissector for a TCP-based protocol. I have a
> conversation state object of my proto which is managed by
> conversation_*_proto_data(). The state object is alloced by
> se_alloc(), so it has a lifetime of capture, but the object itself
> contains libgcrypt handles which are alloced by g_malloc. How should I
> free these handles? Is there any mean to catch the moment when my
> state object is about to be destroyed?

If you register a routine with register_init_routine() (the routine takes no arguments and returns no value), it will be called *after* all the se_alloc()ated memory is freed.  Will that suffice?