Wireshark-dev: Re: [Wireshark-dev] [Wireshark-commits] rev 35253: /trunk/ /trunk/doc/: README.d
From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Mon, 3 Jan 2011 02:08:24 -0800
On Jan 3, 2011, at 12:50 AM, news.gmane.com wrote:

> "Stephen Fisher" <steve@xxxxxxxxxxxxxxxxxx>
> wrote in message news:20101223181634.GA30749@xxxxxxxxxxxxxxxxxxxxxxxxx...
>> I've introduced a new function called tvb_get_ephemeral_unicode_string()
>> for converting UTF-16 strings in a tvbuff to UTF-8 for display in
>> Wireshark.  This new function even works with tshark (at least on Unix)
>> if using a UTF-8 compatiable terminal emulator:
> 
> Does this replaces tvb_get_ephemeral_faked_unicode?
> The function name suggests, that the return value must be released.

Within the context of Wireshark, no, it doesn't; it suggests, due to the "ephemeral" in the name, that it's automatically released when dissection is started on a new packet, although, given that most routines that return ephemerally-allocated memory have just "ep_" at the beginning the name, it should perhaps be named "ep_tvb_get_unicode_string()" or something such as that to make it clearer.  (Yes, tvb_get_ephemeral_faked_unicode() had "ephemeral", not "ep", in its name, but that was arguably an error as well.  "ep_" should come before "tvb_", as other ephemeral-allocation routines have names that begin with "ep_", including "ep_tvb_memdup()".)

> Is there
> also a function returning a string that will be garbage collected?

No - Wireshark doesn't do garbage collection (unless one or more of the extension languages does, and then it does it only for items allocated in the environment for the extension languages in question, courtesy of the language's garbage collector).  It just does "ephemeral" and "session" allocation, where all items allocated with a particular lifetime are automatically released in bulk.