GLib.List.append
Description: Reference for GLib.List.append

### Function

# GLib Listappend

#### Declaration

    GList*
    g_list_append (
      GList* list,
      gpointer data
    )

#### Description

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.

`g_list_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 use `g_list_prepend()` and reverse the list with `g_list_reverse()` when all elements have been added.

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

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

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

This function is not directly available to language bindings.

#### Parameters

`list`

  Type: A list of `gpointer`

  A pointer to a `GList`.

  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 `GList` if `list` was `NULL`.

The data is owned by the called function.