On 26/02/2013 10:17, Daniel Silverstone wrote:
On Tue, Feb 26, 2013 at 07:05:05AM +0000, John-Mark Bell wrote:
> On Mon, 2013-02-25 at 20:10 +0000, Chris Young wrote:
>> I must be msising something, but libwapcaplet allocates a "bucket" in
>> lwc__initialise(). As far as I can tell, this is never freed - as
>> there is no lwc__finalise or equivalent function?
> Correct -- this is expected. There's no safe way to do this without
> adding a context to the lwc API. That introduces a significant amount of
> pain in clients (as they have to pass the context around internally,
> which is problematic when you have multiple things using it. Thus, the
> root hash bucket is leaked, instead.
> I guess we could free the bucket when there are no strings left in it,
> however. Daniel: any thoughts?
It seems a tad silly to add a check to *every* unref to decide if we can free
the root bucket. Esp. given that with all the libs in use, that root bucket
will only ever empty fully immediately before exit.
Or rather actually (hopefully) before unloading the library.
At least on BeOS we can in theory include NetSurf as a replicant, where
the binary is dlopen()ed and dlclosed() when removed, so using atexit()
would cause quite some trouble there.
Instead there are almost-standard hooks for use in libraries, though the
names differ between OSes they are usually always usable.
On ELF-based things it's usually _fini() though the dlopen man on linux
mentions them as deprecated in favor of __attribute__((destructor)).