}
void connection_del(connection_t *c) {
- for list_each(connection_t, c, connection_list) {
- if(node->data == c) {
- list_delete_node(connection_list, node);
- return;
- }
- }
+ list_delete(connection_list, c);
}
bool dump_connections(connection_t *cdump) {
list_delete_node(list, list->tail);
}
+void list_delete(list_t *list, const void *data) {
+ for(list_node_t *node = list->head, *next; next = node ? node->next : NULL, node; node = next)
+ if(node->data == data)
+ list_delete_node(list, node);
+}
+
/* Head/tail lookup */
void *list_get_head(list_t *list) {
/* Fast list deletion */
void list_delete_list(list_t *list) {
- for(list_node_t *node = list->head, *next; next = node->next, node; node = next)
+ for(list_node_t *node = list->head, *next; next = node ? node->next : NULL, node; node = next)
list_free_node(list, node);
list_free(list);
/* Traversing */
void list_foreach_node(list_t *list, list_action_node_t action) {
- for(list_node_t *node = list->head, *next; next = node->next, node; node = next)
+ for(list_node_t *node = list->head, *next; next = node ? node->next : NULL, node; node = next)
action(node);
}
void list_foreach(list_t *list, list_action_t action) {
- for(list_node_t *node = list->head, *next; next = node->next, node; node = next)
+ for(list_node_t *node = list->head, *next; next = node ? node->next : NULL, node; node = next)
if(node->data)
action(node->data);
}
extern list_node_t *list_insert_after(list_t *, list_node_t *, void *);
extern list_node_t *list_insert_before(list_t *, list_node_t *, void *);
+extern void list_delete(list_t *, const void *);
+
extern void list_unlink_node(list_t *, list_node_t *);
extern void list_delete_node(list_t *, list_node_t *);