Once.initEnterPointer

bool initEnterPointer(void * location)

This functions behaves in the same way as [glib.once.Once.initEnter], but can can be used to initialize pointers (or #guintptr) instead of #gsize.

static MyStruct *interesting_struct = NULL;

 if (g_once_init_enter_pointer (&interesting_struct))
   {
     MyStruct *setup_value = allocate_my_struct (); // initialization code here

     g_once_init_leave_pointer (&interesting_struct, g_steal_pointer (&setup_value));
   }

 // use interesting_struct here

Parameters

locationlocation of a static initializable variable containing NULL

Returns

true if the initialization section should be entered,

false and blocks otherwise