dl_delete()

dl_delete()#

Removes a specified item from a doubly linked list and optionally frees its memory.

Prototype

int dl_delete(
    dl_list_t *dl,
    void *curr_,
    void (*fnfree)(void *)
);

Parameters

Key

Type

Description

dl

dl_list_t *

Pointer to the doubly linked list from which the item will be removed.

curr_

void *

Pointer to the item to be removed from the list.

fnfree

void (*)(void *)

Optional function pointer to free the memory of the removed item.


Return Value

Returns 0 on success, or -1 if an error occurs (e.g., null item, empty list, or item not found).

Notes

The function ensures that the list remains consistent after deletion. If fnfree is provided, it is called to free the memory of the removed item.

Prototype

// Not applicable in JS

Prototype

# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples