* Remove the first node in @l. The list can be empty.
**/
/**
* Remove the first node in @l. The list can be empty.
**/
-static inline void slist_remove_head(slist *l)
+static inline void *slist_remove_head(slist *l)
{
{
- slist_remove_after(l, &l->head);
+ snode *n = slist_head(l);
+ if (n)
+ slist_remove_after(l, &l->head);
+ return n;
}
/* Loops */
}
/* Loops */
+/**
+ * Loop over all nodes in the @list and perform the next C statement on them. The current node is stored in @n which must be defined before as pointer to any type.
+ * The list should not be changed during this loop command.
+ * Same as @SLIST_WALK(), but allows removal of the current node. This macro requires one more variable to store the pointer to the previous node (useful for @slist_remove_after()).