### Method

# GObject Object set_data

#### Declaration

    void
    g_object_set_data (
      GObject* object,
      const gchar* key,
      gpointer data
    )

#### Description

Each object carries around a table of associations from strings to pointers. This function lets you set an association.

If the object already had an association with that name, the old association will be destroyed.

Internally, the `key` is converted to a `GQuark` using g_quark_from_string(). This means a copy of `key` is kept permanently (even after `object` has been finalized) — so it is recommended to only use a small, bounded set of values for `key` in your program, to avoid the `GQuark` storage growing unbounded.

#### Parameters

`key`

  Type: `const gchar*`

  Name of the key.

  The data is owned by the caller of the method.
  The value is a NUL terminated UTF-8 string.

`data`

  Type: `gpointer`

  Data to associate with that key.

  The argument can be `NULL`.
  The data is owned by the caller of the method.