Messages in this thread | | | From | Peter Chubb <> | Date | Thu, 26 Sep 2002 10:14:19 +1000 | Subject | [PATCH][2.5] Single linked lists for Linux |
| |
+ +/** + * slist_del - remove an entry from list + * @head: head to remove it from + * @entry: entry to be removed + */ +#define slist_del(_head, _entry) \ +do { \ + (_head)->next = (_entry)->next; \ + (_entry)->next = NULL; \ +} +
This only works if head->next == entry otherwise you lose half your list. Also, none of this is SMP-safe.
I think you need something like this (but with locking!)
/* * remove entry from list starting at head * Return 0 if successful, non-zero otherwise. */ static inline int slist_del(struct slist *head, struct slist *entry) { struct slist **p; for (p = &head->next; *p; p = &(*p)->next) if (*p == entry) { *p = entry->next; entry->next = NULL; return 0; } return -1; }
Peter C - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |