From 80d73629bfca732e6bb847708689c8a03933b963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20O=2E=20Sel=C3=A5sdal?= Date: Thu, 28 Nov 2013 20:01:25 +0100 Subject: [PATCH] add uc_tailq_link() and use it in uc_tailq_remove() --- include/ucore/tailq.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/ucore/tailq.h b/include/ucore/tailq.h index 08a2d47..ab4f0e2 100644 --- a/include/ucore/tailq.h +++ b/include/ucore/tailq.h @@ -85,13 +85,20 @@ static UC_INLINE void uc_tailq_insert_head(struct TailQ *head, struct TailQ *ent uc_tailq_insert(entry, head, head->next); } +/** Link the first and second entry together, + */ +static UC_INLINE void uc_tailq_link(struct TailQ *first, struct TailQ *second) +{ + first->next = second; + second->prev = first; +} + /** Remove the entry from the list it is part of. * (It *must* already be part of a list. */ static UC_INLINE void uc_tailq_remove(struct TailQ *entry) { - entry->prev->next = entry->next; - entry->next->prev = entry->prev; + uc_tailq_link(entry->prev, entry->next); //help catch illegal use: entry->next = (void*)0x101;