Difference between pages "r6:Function:slist delete element" and "r6:Function:slist get head"

From liblfds.org
(Difference between pages)
Jump to navigation Jump to search
m (1 revision imported)
 
m (1 revision imported)
 
Line 1: Line 1:
==Source Files==
==Source Files==
  /src/slist/slist_delete.c
  /src/slist/slist_get_and_set.c
  /inc/liblfds.h
  /inc/liblfds.h


==Prototype==
==Prototype==
  void slist_delete_element( struct slist_state *ss, struct slist_element *se );
  struct slist_element *slist_get_head( struct slist_state *ss, struct slist_element **se );


==Parameters==
==Parameters==
Line 10: Line 10:
: An slist state as allocated by ''[[r6:Function:slist_new|slist_new]]''.
: An slist state as allocated by ''[[r6:Function:slist_new|slist_new]]''.


''struct slist_element *se''
''struct slist_element **se''
: A pointer to an slist element, as obtained from ''[[r6:Function:slist_new_head|slist_new_head]]'', ''[[r6:Function:slist_new_next|slist_new_next]]'', ''[[r6:Function:slist_get_head|slist_get_head]]'', ''[[r6:Function:slist_get_next|slist_get_next]]'' or ''[[r6:Function:slist_get_head_and_then_next|slist_get_head_and_then_next]]''.
: A pointer to a pointer into which the slist element will be placed.  Set to NULL if there are no elements.


==Return Value==
==Return Value==
No return value.
Returns a pointer to the current head element.  Returns NULL if there are no elements.


==Notes==
==Notes==
This function logically deletes ''se''.  By logically delete, it is meant that the memory for the slist element is not freed and the element remains in the list (thus continuing to affect traversal performance) but that the element is no longer apparent to the user of the list; for example, calling ''slist_get_next'' on the element immediately before a deleted element will return the element immediately after the deleted element.
No notes.
 
It may be that other threads still hold a pointer to the logically deleted element.  The element however is still in the list and all operations on the list properly update the pointers in deleted elements, so it is safe to perform all slist operations on a deleted element so you can also for example call ''slist_new_next'' on a deleted element and insert a new element after the deleted element.
 
As such, it is expected and normal after an element has been deleted to call ''slist_get_next'' to progress on to the next element in the slist.


==See Also==
==See Also==
* [[r6:API:SList|SList]]
* [[r6:API:SList|SList]]
* [[r6:Function:slist_new_head|slist_new_head]]
* [[r6:Function:slist_get_next|slist_get_next]]
* [[r6:Function:slist_new_next|slist_new_next]]
* [[r6:Function:slist_get_head_and_then_next|slist_get_head_and_then_next]]

Latest revision as of 14:07, 4 January 2015

Source Files

/src/slist/slist_get_and_set.c
/inc/liblfds.h

Prototype

struct slist_element *slist_get_head( struct slist_state *ss, struct slist_element **se );

Parameters

struct slist_state *ss

An slist state as allocated by slist_new.

struct slist_element **se

A pointer to a pointer into which the slist element will be placed. Set to NULL if there are no elements.

Return Value

Returns a pointer to the current head element. Returns NULL if there are no elements.

Notes

No notes.

See Also