1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 05:12:57 +01:00

core/list: add remove method

This commit is contained in:
Victor Arino 2016-12-14 13:16:15 +01:00
parent df5888539a
commit be146741c9

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de>
* 2016 TriaGnoSys GmbH
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
@ -16,6 +17,7 @@
* Lists are represented as element pointing to the first actual list element.
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
* @author Víctor Ariño <victor.arino@zii.aero>
*/
#ifndef LIST_H
@ -69,6 +71,27 @@ static inline list_node_t* list_remove_head(list_node_t *list) {
return head;
}
/**
* @brief Removes the node from the list
*
* @param[in] list Pointer to the list itself, where list->next points
* to the root node
* @param[in] node List node to remove from the list
*
* @return removed node, or NULL if empty or not found
*/
static inline list_node_t *list_remove(list_node_t *list, list_node_t *node)
{
while (list->next) {
if (list->next == node) {
list->next = node->next;
return node;
}
list = list->next;
}
return list->next;
}
#ifdef __cplusplus
}
#endif