GLib.steal_handle_id
Description: Reference for GLib.steal_handle_id

### Function

# GLibsteal_handle_id

since: 2.84

#### Declaration [src]

    static inline unsigned int
    g_steal_handle_id (
      unsigned int* handle_pointer
    )

#### Description [src]

Sets `handle_pointer` to `0`, returning the value that was there before.

Conceptually, this transfers the ownership of the handle ID from the referenced variable to the ‘caller’ of the macro (ie: ‘steals’ the handle ID).

This can be very useful to make ownership transfer explicit, or to prevent a handle from being released multiple times. For example:

    void
    maybe_unsubscribe_signal (ContextStruct *data)
    {
      if (some_complex_logic (data))
        {
          g_dbus_connection_signal_unsubscribe (data->connection,
                                                g_steal_handle_id (&data->subscription_id));
          // now data->subscription_id isn’t a dangling handle
        }
    }

While `g_clear_handle_id()` can be used in many of the same situations as `g_steal_handle_id()`, this is one situation where it cannot be used, as there is no way to pass the `GDBusConnection` to a `GClearHandleFunc`.

Available since: 2.84

This function is not directly available to language bindings.

#### Parameters

`handle_pointer`

  Type: `unsigned int*`

  A pointer to a handle ID.

  The argument will be modified by the function.

#### Return value

Type: `unsigned int`

No description available.