Function

GLibOnceinit_enter_pointer

since: 2.80

Declaration

gboolean
g_once_init_enter_pointer (
  void* location
)

Description

This functions behaves in the same way as g_once_init_enter(), 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

Available since: 2.80

Parameters

location

Type: void*

Location of a static initializable variable containing NULL

The data is owned by the caller of the function.

Return value

Type: gboolean

TRUE if the initialization section should be entered, FALSE and blocks otherwise.