Re: [PATCH][2.5] Single linked lists for Linux, overly complicated

Thunder from the hill (thunder@lightweight.ods.org)
Thu, 26 Sep 2002 13:43:41 -0600 (MDT)


Hi,

On Thu, 26 Sep 2002, Rik van Riel wrote:
> On Thu, 26 Sep 2002, Thunder from the hill wrote:
> In the case of slist_del() you HAVE to know it.
>
> Think about removing a single entry from the middle of
> the list ... the entries before and after need to stay
> on the list.

2 solutions without list head:

1.
#define slist_del_next(_entry_in) \
do { \
typeof(_entry_in) _entry = (_entry_in), \
_next = (_entry)->next; \
_entry->next = _next->next; \
_next->next = NULL; \
} while (0)

2. The previous entry points to the address that _entry has. If we
copy _entry somewhere else and overwrite the old _entry with
_entry->next, we made it without knowing the list topology. The
previous->next still points to the new _entry, things are fine.

My problem is just: where to put the old _entry? Anyway, since we're
talking about list entry deletion, we could copy it nowhere and just
overwrite it with _entry->next...

Details, details...

Thunder

-- 
assert(typeof((fool)->next) == typeof(fool));	/* wrong */

- 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/