# ft\_lstdelone

### Subject

{% code overflow="wrap" %}

```
FT_LSTDELONE (simplified)

NAME
    ft_lstdelone -- removes one element from the list
SYNOPSIS
    void ft_lstdelone(t_list *lst, void (*del)(void *));
DESCRIPTION
    Free the memory of the element passed as parameter using the 'del' function then free(3). The memory of 'next' must not be freed.
PARAMETERS
    lst: the element to free
    del: address of the function that can delete the element's content
RETURN VALUES
    None
AUTHORIZED EXTERNAL FUNCTIONS
    free(3)
```

{% endcode %}

### Understandable explanation

This function takes a list element as parameter and deletes its content as well as free the allocated memory using the `del` function passed as parameter too.

### Hints

{% code overflow="wrap" %}

```c
/* use the delete function on the element's content */
/* free the element */
```

{% endcode %}

### Commented solution

<details>

<summary>ft_lstdelone</summary>

{% code title="ft\_lstdelone.c" overflow="wrap" lineNumbers="true" %}

```c
#include "libft.h"

void ft_lstdelone(t_list *lst, void (*del)(void *))
{
    /* use the del function on the element's content */
    del(lst->content);
    /* free the element */
    free(lst);
}
```

{% endcode %}

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://42-cursus.gitbook.io/guide/0-rank-00/libft/bonus-functions/ft_lstdelone.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
