libisdn
dlist.c File Reference
#include <stdlib.h>
#include "common.h"
#include "dlist.h"

Go to the source code of this file.

Functions

void dlist_init_head (struct dlist_head *h)
 Initialize linked list.
void dlist_init (struct dlist_head *e)
void dlist_insert_after (struct dlist_head *elem, struct dlist_head *enew)
 Insert new element after given one.
void dlist_insert_before (struct dlist_head *elem, struct dlist_head *enew)
 Insert new element before given one.
void dlist_insert_tail (struct dlist_head *list, struct dlist_head *enew)
 Insert new element at the end of the list.
void dlist_remove (struct dlist_head *elem)
 Remove element from the list.
struct dlist_headdlist_first (const struct dlist_head *list)
 Get first element in the list.
struct dlist_headdlist_last (const struct dlist_head *list)
 Get last element in the list.
struct dlist_headdlist_next (const struct dlist_head *elem)
 Get next element after given one.
struct dlist_headdlist_prev (const struct dlist_head *elem)
 Get element before given one.
struct dlist_headdlist_pop_head (const struct dlist_head *elem)
struct dlist_headdlist_pop_tail (const struct dlist_head *elem)
int dlist_is_head (const struct dlist_head *elem)
 Check if the element passed is the list head.
int dlist_is_first (const struct dlist_head *elem)
 Check if the element passed is the first one.
int dlist_is_last (const struct dlist_head *elem)
 Check if the element passed is the last one.
void dlist_replace (struct dlist_head *old, struct dlist_head *enew)
 Replace an element in the list with a new one.

Function Documentation

struct dlist_head* dlist_first ( const struct dlist_head elem) [read]

Get first element in the list.

dlist_first

Parameters:
[in]elemAny list element
Returns:
First element

Definition at line 96 of file dlist.c.

References dlist_head::head, and dlist_head::next.

Referenced by dlist_pop_head().

void dlist_init ( struct dlist_head e)

Definition at line 22 of file dlist.c.

References dlist_head::head, dlist_head::next, and dlist_head::prev.

void dlist_init_head ( struct dlist_head h)

Initialize linked list.

dlist_init_head

Parameters:
[in]hpointer to linked list head

Definition at line 15 of file dlist.c.

References dlist_head::head, dlist_head::next, and dlist_head::prev.

Referenced by msgb_fifo_init().

void dlist_insert_after ( struct dlist_head elem,
struct dlist_head enew 
)

Insert new element after given one.

dlist_insert_after

Parameters:
[in]elemElement to insert after
[in]newNew element

Definition at line 29 of file dlist.c.

References dlist_head::head, dlist_head::next, and dlist_head::prev.

Referenced by dlist_insert_tail().

void dlist_insert_before ( struct dlist_head elem,
struct dlist_head enew 
)

Insert new element before given one.

dlist_insert_before

Parameters:
[in]elemElement to insert before
[in]newNew element

Definition at line 46 of file dlist.c.

References dlist_head::head, dlist_head::next, and dlist_head::prev.

void dlist_insert_tail ( struct dlist_head list,
struct dlist_head enew 
)

Insert new element at the end of the list.

dlist_insert_tail

Parameters:
[in]listThe list
[in]newNew element

Definition at line 61 of file dlist.c.

References dlist_insert_after(), dlist_head::head, dlist_head::next, and dlist_head::prev.

Referenced by msgb_fifo_enqueue().

int dlist_is_first ( const struct dlist_head elem)

Check if the element passed is the first one.

dlist_is_first

Parameters:
[in]elemAny list element
Returns:
0 if the element passed is not the first, 1 otherwise

Definition at line 148 of file dlist.c.

References dlist_head::head, and dlist_head::prev.

int dlist_is_head ( const struct dlist_head elem)

Check if the element passed is the list head.

dlist_is_head

Parameters:
[in]elemAny list element
Returns:
0 if the element passed is not the head, 1 otherwise

Definition at line 142 of file dlist.c.

References dlist_head::head.

int dlist_is_last ( const struct dlist_head elem)

Check if the element passed is the last one.

dlist_is_last

Parameters:
[in]elemAny list element
Returns:
0 if the element passed is not the last, 1 otherwise

Definition at line 154 of file dlist.c.

References dlist_head::head, and dlist_head::next.

struct dlist_head* dlist_last ( const struct dlist_head elem) [read]

Get last element in the list.

dlist_last

Parameters:
[in]elemAny list element
Returns:
Last element

Definition at line 104 of file dlist.c.

References dlist_head::head, and dlist_head::prev.

Referenced by dlist_pop_tail().

struct dlist_head* dlist_next ( const struct dlist_head elem) [read]

Get next element after given one.

dlist_next

Parameters:
[in]elemAny list element
Returns:
Next element

Definition at line 112 of file dlist.c.

References dlist_head::head, and dlist_head::next.

struct dlist_head* dlist_pop_head ( const struct dlist_head elem) [read]

Remove and return first element of list

Parameters:
[in]elemList
Returns:
First element of list or NULL if list is empty

Definition at line 128 of file dlist.c.

References dlist_first(), and dlist_remove().

Referenced by msgb_fifo_dequeue().

struct dlist_head* dlist_pop_tail ( const struct dlist_head elem) [read]

Remove and return last element of list

Parameters:
[in]elemList
Returns:
Last element of list or NULL if list is empty

Definition at line 135 of file dlist.c.

References dlist_last(), and dlist_remove().

struct dlist_head* dlist_prev ( const struct dlist_head elem) [read]

Get element before given one.

dlist_prev

Parameters:
[in]elemAny list element
Returns:
Previous element

Definition at line 120 of file dlist.c.

References dlist_head::head, and dlist_head::prev.

void dlist_remove ( struct dlist_head elem)

Remove element from the list.

dlist_remove

Parameters:
[in]elemElement to remove

Definition at line 79 of file dlist.c.

References dlist_head::head, dlist_head::next, and dlist_head::prev.

Referenced by dlist_pop_head(), and dlist_pop_tail().

void dlist_replace ( struct dlist_head old,
struct dlist_head enew 
)

Replace an element in the list with a new one.

dlist_replace

Parameters:
[in]oldElement to replace
[in]newReplacement

Definition at line 159 of file dlist.c.

References dlist_head::head, dlist_head::next, and dlist_head::prev.