Initialisation/Finalisation



All the G*{Init,Finalize}Funcs confuse me!

There are five of them:

-- GBaseInitFunc 
-- GBaseFinalizeFunc 
-- GClassInitFunc 
-- GClassFinalizeFunc 
-- GInstanceInitFunc 

My Questions are: 

1. The Finalize func undoes the Init func.  Fair enough.  But why is
   there no GInstanceFinalizeFunc?  See example below:

2. I can't work out from the documentation what the purpose of the
   GBase{Init,Finalise} func is, beyond that it has something to do
   with derived objects.  
   Is GBase* called once per instance, or once  per class? 

3. And does the word `Base' imply the parent of the current object, or
   simply that the current object is expected to have derived objects.

4. The documentation talks about the initialisation sequence, but
   doesn't make clear what is the responsibility of the programmer,
   and what (if anything) is done automatically by the library.





I have a gobject, whose _new function looks like :

GObject* 
pgc_new(const gchar *c)
{
  PGC *pg;

  pg = PGC(g_object_new(TYPE_PGC,0));

  g_assert(pg);

  pg->info = g_strdup(c);

  return G_OBJECT(pg);

}


Now the doco for g_strdup says that the pointer returned must be freed
when no longer needed.  But how and when can I do that ??  It needs to
be freed when the object is destroyed, but there is no
GInstanceFinalizeFunc which (to me) would seem the logical thing to
have.


Thanks for your help.

J'



-- 
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://www.keyserver.net or any PGP keyserver for public key.


Attachment: pgpzMsL9A0Gdi.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]