ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: Re: [Wireshark-dev] [PATCH][UPDATE] ptvcursor : one step further?

From: Sebastien Tandel <sebastien@xxxxxxxxx>
Date: Sun, 11 Mar 2007 21:53:30 +0100
Hi Guy,

>> About the memory leak with g_renew, you're right of course.
>> "Unfortunately" there is no ep_realloc ... is there any reasons to /not/
>> implement one ? I've no idea of the complexity to implement one either ...
>>     
>
> "realloc" is usually defined as to "allocate new, copy, free old" - and 
> implementations might have an optimization, such that if there's enough 
> free space after the existing item, it'll just be extended into that 
> space, with no copy necessary.
>   
thx for the clarification but ... I had no idea of the complexity of the
implementation in emem.c (with the optimization) ;)
> There's no "ep_free()" (by design), so "ep_realloc()" would be "allocate 
> new, copy" - and I think that the optimization might be implementable, 
> although it'd only work for the most recently allocated item.
>   
That's another interesting question ... Is there a real interest to
implement an "optimization"? Wouldn't be  always a "allocate new, copy"
+ a test on whether there is enough space after the existing item? Which
could be in practice slower than the "dumb" solution : always "allocate
new, copy".

> So, no, I don't see any reason not to implement ep_realloc()
We may start with the simplest solution "allocate new, copy". What do
you think of it?


Regards,
Sebastien Tandel