# lv_ll.h (/api/misc/lv_ll_h)



Handle linked lists. The nodes are dynamically allocated by the 'lv\_mem' module.

<ApiSummary functions="15" structs="1" typedefs="1" macros="2" />

Functions [#functions]

<ApiTabs items="[&#x22;Getters (5)&#x22;,&#x22;Other (10)&#x22;]">
  <ApiTab value="Getters (5)">
    <ApiMember kind="function" name="lv_ll_get_head" file="misc/lv_ll.h" line="101" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_ll.h#L101">
      lv_ll_get_head [#lv_ll_get_head]

      Return with head node of the linked list

      ```c title=" " lineNumbers=1
      void * lv_ll_get_head(const lv_ll_t *ll_p)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name   | Type                                                 | Description            |
      | ------ | ---------------------------------------------------- | ---------------------- |
      | `ll_p` | <ApiLink name="lv_ll_t" display="const lv_ll_t *" /> | pointer to linked list |

      **Returns:** `void *` — pointer to the head of 'll\_p'
    </ApiMember>

    <ApiMember kind="function" name="lv_ll_get_tail" file="misc/lv_ll.h" line="108" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_ll.h#L108">
      lv_ll_get_tail [#lv_ll_get_tail]

      Return with tail node of the linked list

      ```c title=" " lineNumbers=1
      void * lv_ll_get_tail(const lv_ll_t *ll_p)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name   | Type                                                 | Description            |
      | ------ | ---------------------------------------------------- | ---------------------- |
      | `ll_p` | <ApiLink name="lv_ll_t" display="const lv_ll_t *" /> | pointer to linked list |

      **Returns:** `void *` — pointer to the tail of 'll\_p'
    </ApiMember>

    <ApiMember kind="function" name="lv_ll_get_next" file="misc/lv_ll.h" line="116" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_ll.h#L116">
      lv_ll_get_next [#lv_ll_get_next]

      Return with the pointer of the next node after 'n\_act'

      ```c title=" " lineNumbers=1
      void * lv_ll_get_next(const lv_ll_t *ll_p, const void *n_act)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name    | Type                                                 | Description            |
      | ------- | ---------------------------------------------------- | ---------------------- |
      | `ll_p`  | <ApiLink name="lv_ll_t" display="const lv_ll_t *" /> | pointer to linked list |
      | `n_act` | `const void *`                                       | pointer a node         |

      **Returns:** `void *` — pointer to the next node
    </ApiMember>

    <ApiMember kind="function" name="lv_ll_get_prev" file="misc/lv_ll.h" line="124" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_ll.h#L124">
      lv_ll_get_prev [#lv_ll_get_prev]

      Return with the pointer of the previous node after 'n\_act'

      ```c title=" " lineNumbers=1
      void * lv_ll_get_prev(const lv_ll_t *ll_p, const void *n_act)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name    | Type                                                 | Description            |
      | ------- | ---------------------------------------------------- | ---------------------- |
      | `ll_p`  | <ApiLink name="lv_ll_t" display="const lv_ll_t *" /> | pointer to linked list |
      | `n_act` | `const void *`                                       | pointer a node         |

      **Returns:** `void *` — pointer to the previous node
    </ApiMember>

    <ApiMember kind="function" name="lv_ll_get_len" file="misc/lv_ll.h" line="131" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_ll.h#L131">
      lv_ll_get_len [#lv_ll_get_len]

      Return the length of the linked list.

      ```c title=" " lineNumbers=1
      uint32_t lv_ll_get_len(const lv_ll_t *ll_p)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name   | Type                                                 | Description            |
      | ------ | ---------------------------------------------------- | ---------------------- |
      | `ll_p` | <ApiLink name="lv_ll_t" display="const lv_ll_t *" /> | pointer to linked list |

      **Returns:** <ApiLink name="uint32_t" /> — length of the linked list
    </ApiMember>
  </ApiTab>

  <ApiTab value="Other (10)">
    <ApiMember kind="function" name="lv_ll_init" file="misc/lv_ll.h" line="46" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_ll.h#L46">
      lv_ll_init [#lv_ll_init]

      Initialize linked list

      ```c title=" " lineNumbers=1
      void lv_ll_init(lv_ll_t *ll_p, uint32_t node_size)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name        | Type                                           | Description                                    |
      | ----------- | ---------------------------------------------- | ---------------------------------------------- |
      | `ll_p`      | <ApiLink name="lv_ll_t" display="lv_ll_t *" /> | pointer to <ApiLink name="lv_ll_t" /> variable |
      | `node_size` | <ApiLink name="uint32_t" />                    | the size of 1 node in bytes                    |
    </ApiMember>

    <ApiMember kind="function" name="lv_ll_ins_head" file="misc/lv_ll.h" line="53" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_ll.h#L53">
      lv_ll_ins_head [#lv_ll_ins_head]

      Add a new head to a linked list

      ```c title=" " lineNumbers=1
      void * lv_ll_ins_head(lv_ll_t *ll_p)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name   | Type                                           | Description            |
      | ------ | ---------------------------------------------- | ---------------------- |
      | `ll_p` | <ApiLink name="lv_ll_t" display="lv_ll_t *" /> | pointer to linked list |

      **Returns:** `void *` — pointer to the new head
    </ApiMember>

    <ApiMember kind="function" name="lv_ll_ins_prev" file="misc/lv_ll.h" line="61" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_ll.h#L61">
      lv_ll_ins_prev [#lv_ll_ins_prev]

      Insert a new node in front of the n\_act node

      ```c title=" " lineNumbers=1
      void * lv_ll_ins_prev(lv_ll_t *ll_p, void *n_act)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name    | Type                                           | Description            |
      | ------- | ---------------------------------------------- | ---------------------- |
      | `ll_p`  | <ApiLink name="lv_ll_t" display="lv_ll_t *" /> | pointer to linked list |
      | `n_act` | `void *`                                       | pointer a node         |

      **Returns:** `void *` — pointer to the new node
    </ApiMember>

    <ApiMember kind="function" name="lv_ll_ins_tail" file="misc/lv_ll.h" line="68" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_ll.h#L68">
      lv_ll_ins_tail [#lv_ll_ins_tail]

      Add a new tail to a linked list

      ```c title=" " lineNumbers=1
      void * lv_ll_ins_tail(lv_ll_t *ll_p)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name   | Type                                           | Description            |
      | ------ | ---------------------------------------------- | ---------------------- |
      | `ll_p` | <ApiLink name="lv_ll_t" display="lv_ll_t *" /> | pointer to linked list |

      **Returns:** `void *` — pointer to the new tail
    </ApiMember>

    <ApiMember kind="function" name="lv_ll_remove" file="misc/lv_ll.h" line="76" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_ll.h#L76">
      lv_ll_remove [#lv_ll_remove]

      Remove the node 'node\_p' from 'll\_p' linked list. It does not free the memory of node.

      ```c title=" " lineNumbers=1
      void lv_ll_remove(lv_ll_t *ll_p, void *node_p)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name     | Type                                           | Description                             |
      | -------- | ---------------------------------------------- | --------------------------------------- |
      | `ll_p`   | <ApiLink name="lv_ll_t" display="lv_ll_t *" /> | pointer to the linked list of 'node\_p' |
      | `node_p` | `void *`                                       | pointer to node in 'll\_p' linked list  |
    </ApiMember>

    <ApiMember kind="function" name="lv_ll_clear_custom" file="misc/lv_ll.h" line="78" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_ll.h#L78">
      lv_ll_clear_custom [#lv_ll_clear_custom]

      ```c title=" " lineNumbers=1
      void lv_ll_clear_custom(lv_ll_t *ll_p, void(*cleanup)(void *))
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name      | Type                                           |
      | --------- | ---------------------------------------------- |
      | `ll_p`    | <ApiLink name="lv_ll_t" display="lv_ll_t *" /> |
      | `cleanup` | `void(*)(void *)`                              |
    </ApiMember>

    <ApiMember kind="function" name="lv_ll_clear" file="misc/lv_ll.h" line="84" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_ll.h#L84">
      lv_ll_clear [#lv_ll_clear]

      Remove and free all elements from a linked list. The list remain valid but become empty.

      ```c title=" " lineNumbers=1
      void lv_ll_clear(lv_ll_t *ll_p)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name   | Type                                           | Description            |
      | ------ | ---------------------------------------------- | ---------------------- |
      | `ll_p` | <ApiLink name="lv_ll_t" display="lv_ll_t *" /> | pointer to linked list |
    </ApiMember>

    <ApiMember kind="function" name="lv_ll_chg_list" file="misc/lv_ll.h" line="94" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_ll.h#L94">
      lv_ll_chg_list [#lv_ll_chg_list]

      Move a node to a new linked list

      ```c title=" " lineNumbers=1
      void lv_ll_chg_list(lv_ll_t *ll_ori_p, lv_ll_t *ll_new_p, void *node, bool head)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name       | Type                                           | Description                                                         |
      | ---------- | ---------------------------------------------- | ------------------------------------------------------------------- |
      | `ll_ori_p` | <ApiLink name="lv_ll_t" display="lv_ll_t *" /> | pointer to the original (old) linked list                           |
      | `ll_new_p` | <ApiLink name="lv_ll_t" display="lv_ll_t *" /> | pointer to the new linked list                                      |
      | `node`     | `void *`                                       | pointer to a node                                                   |
      | `head`     | <ApiLink name="bool" />                        | true: be the head in the new list false be the tail in the new list |
    </ApiMember>

    <ApiMember kind="function" name="lv_ll_move_before" file="misc/lv_ll.h" line="148" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_ll.h#L148">
      lv_ll_move_before [#lv_ll_move_before]

      Move a node before another node in the same linked list

      ```c title=" " lineNumbers=1
      void lv_ll_move_before(lv_ll_t *ll_p, void *n_act, void *n_after)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name      | Type                                           | Description                                     |
      | --------- | ---------------------------------------------- | ----------------------------------------------- |
      | `ll_p`    | <ApiLink name="lv_ll_t" display="lv_ll_t *" /> | pointer to a linked list                        |
      | `n_act`   | `void *`                                       | pointer to node to move                         |
      | `n_after` | `void *`                                       | pointer to a node which should be after `n_act` |
    </ApiMember>

    <ApiMember kind="function" name="lv_ll_is_empty" file="misc/lv_ll.h" line="155" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_ll.h#L155">
      lv_ll_is_empty [#lv_ll_is_empty]

      Check if a linked list is empty

      ```c title=" " lineNumbers=1
      bool lv_ll_is_empty(lv_ll_t *ll_p)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name   | Type                                           | Description              |
      | ------ | ---------------------------------------------- | ------------------------ |
      | `ll_p` | <ApiLink name="lv_ll_t" display="lv_ll_t *" /> | pointer to a linked list |

      **Returns:** <ApiLink name="bool" /> — true: the linked list is empty; false: not empty
    </ApiMember>
  </ApiTab>
</ApiTabs>

Structs [#structs]

<ApiMember kind="struct" name="lv_ll_t">
  lv_ll_t [#lv_ll_t]

  Description of a linked list

  | Member   | Type                                                     | Description |
  | -------- | -------------------------------------------------------- | ----------- |
  | `n_size` | <ApiLink name="uint32_t" />                              |             |
  | `head`   | <ApiLink name="lv_ll_node_t" display="lv_ll_node_t *" /> |             |
  | `tail`   | <ApiLink name="lv_ll_node_t" display="lv_ll_node_t *" /> |             |
</ApiMember>

<TypeUsedBy name="lv_ll_t" count="17">
  * `lv_vector_for_each_destroy_tasks` — param `task_list`
  * `lv_ll_init` — param `ll_p`
  * `lv_ll_ins_head` — param `ll_p`
  * `lv_ll_ins_prev` — param `ll_p`
  * `lv_ll_ins_tail` — param `ll_p`
  * `lv_ll_remove` — param `ll_p`
  * `lv_ll_clear_custom` — param `ll_p`
  * `lv_ll_clear` — param `ll_p`
  * `lv_ll_chg_list` — param `ll_ori_p`
  * `lv_ll_chg_list` — param `ll_new_p`
  * `lv_ll_get_head` — param `ll_p`
  * `lv_ll_get_tail` — param `ll_p`
  * `lv_ll_get_next` — param `ll_p`
  * `lv_ll_get_prev` — param `ll_p`
  * `lv_ll_get_len` — param `ll_p`
  * `lv_ll_move_before` — param `ll_p`
  * `lv_ll_is_empty` — param `ll_p`
</TypeUsedBy>

Typedefs [#typedefs]

<ApiMember kind="typedef" name="lv_ll_node_t" file="misc/lv_ll.h" line="28" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_ll.h#L28">
  lv_ll_node_t [#lv_ll_node_t]

  ```c title=" " lineNumbers=1
  typedef uint8_t lv_ll_node_t
  ```

  Dummy type to make handling easier
</ApiMember>

Macros [#macros]

<ApiMember kind="macro" name="LV_LL_READ" file="misc/lv_ll.h" line="161" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_ll.h#L161">
  LV_LL_READ [#lv_ll_read]

  ```c title=" " lineNumbers=1
  #define LV_LL_READ(list, i) \
      for(i = lv_ll_get_head(list); i != NULL; i = lv_ll_get_next(list, i))
  ```
</ApiMember>

<ApiMember kind="macro" name="LV_LL_READ_BACK" file="misc/lv_ll.h" line="163" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_ll.h#L163">
  LV_LL_READ_BACK [#lv_ll_read_back]

  ```c title=" " lineNumbers=1
  #define LV_LL_READ_BACK(list, i) \
      for(i = lv_ll_get_tail(list); i != NULL; i = lv_ll_get_prev(list, i))
  ```
</ApiMember>

Dependencies [#dependencies]

<FileIncludes includes="[&#x22;lv_conf_internal.h&#x22;, &#x22;lv_types.h&#x22;]" includedBy="[&#x22;lv_global.h&#x22;, &#x22;lv_group.h&#x22;, &#x22;lv_freetype_private.h&#x22;, &#x22;lv_anim.h&#x22;, &#x22;lv_timer.h&#x22;]" transitiveIncludes="[&#x22;lv_conf_kconfig.h&#x22;]" />
