|
From: | Marc Nieper-Wißkirchen |
Subject: | Re: Node to first or last element of a sequential list in module list/xlist |
Date: | Sat, 3 Apr 2021 12:00:26 +0200 |
Marc Nieper-Wißkirchen wrote:
> > I don't understand. You want to use a list_node_t while adding nodes to
> > the list? This is invalid, since the comments in gl_list.h say:
> >
> > /* Type representing the position of an element in the list, in a way
> > that
> > is more adapted to the list implementation than a plain index.
> > Note: It is invalidated by insertions and removals! */
> > typedef struct gl_list_node_impl * gl_list_node_t;
> >
>
> It won't work with removals but it does work with insertions because
> gl_list_add_before/gl_list_add_after/... etc. all return new, valid list
> node objects.
While this may be true for the linked-list implementation, it is not true
for the array-list and other implementation. But the point of the Gnulib
list module is to allow the developer to switch to a different implementation
without changing their algorithms. [1]
[Prev in Thread] | Current Thread | [Next in Thread] |