GLib.SList.append
Description: Reference for GLib.SList.append

### Function

# GLib SListappend

#### Declaration [src]

    GSList*
    g_slist_append (
      GSList* list,
      gpointer data
    )

#### Description [src]

Adds a new element on to the end of the list.

Note that the return value is the new start of the list if `list` was empty; make sure you store the new value.

Note that `g_slist_append()` has to traverse the entire list to find the end, which is inefficient when adding multiple elements. A common idiom to avoid the inefficiency is to prepend the elements and reverse the list when all elements have been added.

    // Notice that these are initialized to the empty list.
    GSList *list = NULL, *number_list = NULL;

    // This is a list of strings.
    list = g_slist_append (list, "first");
    list = g_slist_append (list, "second");

    // This is a list of integers.
    number_list = g_slist_append (number_list, GINT_TO_POINTER (27));
    number_list = g_slist_append (number_list, GINT_TO_POINTER (14));

This function is not directly available to language bindings.

#### Parameters

`list`

  Type: A list of `gpointer`

  A `GSList`.

  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`

Either `list` or the new start of the `GSList` if `list` was `NULL`.

The data is owned by the called function.