Function

GLib-2.0GLibonce_init_enter_pointerSince 2.80

  • 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

    Parameters

    • location: any

      location of a static initializable variable containing NULL

    Returns boolean

    true if the initialization section should be entered, false and blocks otherwise

    2.80