GObject ref counting



Is it good practice always to ref count GObject's passed into functions -- 
even if you know for certain that the primary reference is in your control, 
i.e. the first reference cannot be unref'd by surprise?

For large, complex objects with many api's, most of which are private,
I find that all this reference counting appears to be useless since I
have the creation reference safely in my control.

In other words:

void foo (GObject *obj)
{
   g_object_ref (obj);   <-- redundant?

   /* do something */

   g_object_unef (obj);  <-- redundant?
}

int my_private_function ()
{
   GObject *obj = create_my_object (...);

   foo (obj);

   g_object_unref (obj);
}





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