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

Ethereal-dev: [Ethereal-dev] ememification of tvb_get_tring() and friends

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

From: ronnie sahlberg <ronniesahlberg@xxxxxxxxx>
Date: Thu, 28 Jul 2005 06:21:26 -0400
List

during my crusade to ememify the tvb_get_string() (and friends such as
tvb_fake_unicode(), tvb_get_text(), tvb_get_stringz())
i have found several obvious memleaks (and a lot more nonobvious like
where an exception is thrown between where tvb_get_string() is called
and before g_free()) which is good.

since virtually all users of these functions only want to get a string
pointer to do some additional processing and/or formated display of
the string  my plan is to finish ememify this family of
functions/helpers using an ep_ prepended name  and once all of them
are refactored this way  in one big chunk rename them back to tvb_...

This will revert back to the original symbol names but only changing
the semantics to "no need to explicitely free the memory allocated".

Something that would imho be good since the number of both obvious and
non-obvious memleaks for these calls show that the api in using them
is too complex.
it would probably also speed up ethereal a tiny tiny fraction reducing
the amount of g_free() calls made but that is likely insignificant.


once this is finished i plan not to have any explicit
ep_tvb_get_string() calls anymore. only the tvb_get_string() and
friends but with a different semantic on how/when memory is freed.
Since so very few functions actually need tvb_get_string() data with
longer than to the end of dissecting the current packet semantics
those other very few users can just do their own g_strdup()/g_free()  
  or when added ec_alloc() call (like ep_alloc() but with lifetime
until new capture is loaded).


comments?