GLib.List.prepend
Description: Reference for GLib.List.prepend

### Function

# GLib Listprepend

#### Declaration [src]

    GList*
    g_list_prepend (
      GList* list,
      gpointer data
    )

#### Description [src]

Prepends a new element on to the start of the list.

Note that the return value is the new start of the list, which will have changed, so make sure you store the new value.

    // Notice that it is initialized to the empty list.
    GList *list = NULL;

    list = g_list_prepend (list, "last");
    list = g_list_prepend (list, "first");

Do not use this function to prepend a new element to a different element than the start of the list. Use `g_list_insert_before()` instead.

This function is not directly available to language bindings.

#### Parameters

`list`

  Type: A list of `gpointer`

  A pointer to a `GList`, this must point to the top of the list.

  The data is owned by the caller of the function.

`data`

  Type: `gpointer`

  The data for the new element.

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

#### Return value

Type: A list of `gpointer`

A pointer to the newly prepended element, which is the new start of the `GList`.

The data is owned by the called function.