From 1f578af595de63a577b13f0c7adc8693a6645d94 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 15 Jan 2001 09:36:26 +0000 Subject: [PATCH] Added an explanatory comment. --- lib/lists.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/lists.h b/lib/lists.h index 0c0ab0f6..fa9599aa 100644 --- a/lib/lists.h +++ b/lib/lists.h @@ -7,6 +7,19 @@ #ifndef _SHERLOCK_LISTS_H #define _SHERLOCK_LISTS_H +/* + * I admit the list structure is very tricky and also somewhat awkward, + * but it's both efficient and easy to manipulate once one understands the + * basic trick: The list head always contains two synthetic nodes which are + * always present in the list: the head and the tail. But as the `next' + * entry of the tail and the `prev' entry of the head are both NULL, the + * nodes can overlap each other: + * + * head head_node.next + * null head_node.prev tail_node.next + * tail tail_node.prev + */ + typedef struct node { struct node *next, *prev; } node; -- 2.39.5