[haiku-development] Re: add-ons and static initializers

  • From: Stephan Assmus <superstippi@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 11 Jun 2008 23:21:12 +0200

Ingo Weinhold wrote:
> 
> On 2008-06-11 at 22:16:29 [+0200], Bruno Albuquerque <bga@xxxxxxxxxxxxx> 
> wrote:
> > Stephan Assmus escreveu:
> > 
> > > just a quick question: Assuming I have an add-on, which links 
> > > statically against a library. I need to call an init function in the 
> > > library that is supposed to be called only once per process. If I 
> > > solve this via a static initializer, what happens when an application 
> > > unloads the add-on and reloads it again? Will the static initializer 
> > > always be called whenever the
> > > add-on is loaded? I am talking about the Xvid decoder, if you want to 
> > > look at the code.
> > 
> > I am pretty sure it would be ran all the time. otherwise when you 
> > unloaded it there would be left-overs of it.
> 
> Yep, the runtime loader invokes the constructors whenever a shared object 
> (add-on in this case) has been loaded and the destructors when it is 
> about to be unloaded.

Thank you both! I just started to wonder, it wasn't a problem I was 
observing or anything... :-)

Best regards,
-Stephan

Other related posts: