libwebsockets
Lightweight C library for HTML5 websockets
linked-lists

Data Structures

struct  lws_dll2
 
struct  lws_dll2_owner
 

Macros

#define lws_start_foreach_ll(type, it, start)
 
#define lws_end_foreach_ll(it, nxt)
 
#define lws_start_foreach_ll_safe(type, it, start, nxt)
 
#define lws_end_foreach_ll_safe(it)
 
#define lws_start_foreach_llp(type, it, start)
 
#define lws_start_foreach_llp_safe(type, it, start, nxt)
 
#define lws_end_foreach_llp(it, nxt)
 
#define lws_end_foreach_llp_safe(it)
 
#define lws_ll_fwd_insert(___new_object, ___m_list, ___list_head)
 
#define lws_ll_fwd_remove(___type, ___m_list, ___target, ___list_head)
 
#define lws_dll2_search_sz_pl(own, name, namelen, type, membd2list, membptr)
 
#define lws_dll2_describe(x, y)
 
#define lws_start_foreach_dll_safe(___type, ___it, ___tmp, ___start)
 
#define lws_end_foreach_dll_safe(___it, ___tmp)
 
#define lws_start_foreach_dll(___type, ___it, ___start)
 
#define lws_end_foreach_dll(___it)
 

Typedefs

typedef struct lws_dll2 lws_dll2_t
 
typedef struct lws_dll2_owner lws_dll2_owner_t
 
typedef int(* lws_dll2_foreach_cb_t) (struct lws_dll2 *d, void *user)
 

Functions

LWS_VISIBLE LWS_EXTERN int lws_dll2_is_detached (const struct lws_dll2 *d)
 
LWS_VISIBLE LWS_EXTERN void lws_dll2_add_head (struct lws_dll2 *d, struct lws_dll2_owner *owner)
 
LWS_VISIBLE LWS_EXTERN void lws_dll2_add_tail (struct lws_dll2 *d, struct lws_dll2_owner *owner)
 
LWS_VISIBLE LWS_EXTERN void lws_dll2_remove (struct lws_dll2 *d)
 
LWS_VISIBLE LWS_EXTERN int lws_dll2_foreach_safe (struct lws_dll2_owner *owner, void *user, lws_dll2_foreach_cb_t cb)
 
LWS_VISIBLE LWS_EXTERN void lws_dll2_clear (struct lws_dll2 *d)
 
LWS_VISIBLE LWS_EXTERN void lws_dll2_owner_clear (struct lws_dll2_owner *d)
 
LWS_VISIBLE LWS_EXTERN void lws_dll2_add_before (struct lws_dll2 *d, struct lws_dll2 *after)
 
LWS_VISIBLE LWS_EXTERN void lws_dll2_add_insert (struct lws_dll2 *d, struct lws_dll2 *prev)
 
LWS_VISIBLE LWS_EXTERN void lws_dll2_add_sorted (lws_dll2_t *d, lws_dll2_owner_t *own, int(*compare)(const lws_dll2_t *d, const lws_dll2_t *i))
 
LWS_VISIBLE LWS_EXTERN void lws_dll2_add_sorted_priv (lws_dll2_t *d, lws_dll2_owner_t *own, void *priv, int(*compare3)(void *priv, const lws_dll2_t *d, const lws_dll2_t *i))
 
LWS_VISIBLE LWS_EXTERN void * _lws_dll2_search_sz_pl (lws_dll2_owner_t *own, const char *name, size_t namelen, size_t dll2_ofs, size_t ptr_ofs)
 

Detailed Description

Linked list apis

simple single and doubly-linked lists


Data Structure Documentation

◆ lws_dll2

struct lws_dll2

Definition at line 197 of file lws-dll2.h.

+ Collaboration diagram for lws_dll2:
Data Fields
struct lws_dll2 * prev
struct lws_dll2 * next
struct lws_dll2_owner * owner

◆ lws_dll2_owner

struct lws_dll2_owner

Definition at line 203 of file lws-dll2.h.

+ Collaboration diagram for lws_dll2_owner:
Data Fields
struct lws_dll2 * tail
struct lws_dll2 * head
uint32_t count

Macro Definition Documentation

◆ lws_start_foreach_ll

#define lws_start_foreach_ll (   type,
  it,
  start 
)

#include <include/libwebsockets/lws-dll2.h>

Value:
{ \
type it = start; \
while (it) {

lws_start_foreach_ll(): linkedlist iterator helper start

Parameters
typetype of iteration, eg, struct xyz *
ititerator var name to create
startstart of list

This helper creates an iterator and starts a while (it) { loop. The iterator runs through the linked list starting at start and ends when it gets a NULL. The while loop should be terminated using lws_start_foreach_ll().

Definition at line 44 of file lws-dll2.h.

◆ lws_end_foreach_ll

#define lws_end_foreach_ll (   it,
  nxt 
)

#include <include/libwebsockets/lws-dll2.h>

Value:
it = it->nxt; \
} \
}

lws_end_foreach_ll(): linkedlist iterator helper end

Parameters
itsame iterator var name given when starting
nxtmember name in the iterator pointing to next list element

This helper is the partner for lws_start_foreach_ll() that ends the while loop.

Definition at line 59 of file lws-dll2.h.

◆ lws_start_foreach_ll_safe

#define lws_start_foreach_ll_safe (   type,
  it,
  start,
  nxt 
)

#include <include/libwebsockets/lws-dll2.h>

Value:
{ \
type it = start; \
while (it) { \
type next_##it = it->nxt;

lws_start_foreach_ll_safe(): linkedlist iterator helper start safe against delete

Parameters
typetype of iteration, eg, struct xyz *
ititerator var name to create
startstart of list
nxtmember name in the iterator pointing to next list element

This helper creates an iterator and starts a while (it) { loop. The iterator runs through the linked list starting at start and ends when it gets a NULL. The while loop should be terminated using lws_end_foreach_ll_safe(). Performs storage of next increment for situations where iterator can become invalidated during iteration.

Definition at line 79 of file lws-dll2.h.

◆ lws_end_foreach_ll_safe

#define lws_end_foreach_ll_safe (   it)

#include <include/libwebsockets/lws-dll2.h>

Value:
it = next_##it; \
} \
}

lws_end_foreach_ll_safe(): linkedlist iterator helper end (pre increment storage)

Parameters
itsame iterator var name given when starting

This helper is the partner for lws_start_foreach_ll_safe() that ends the while loop. It uses the precreated next_ variable already stored during start.

Definition at line 95 of file lws-dll2.h.

◆ lws_start_foreach_llp

#define lws_start_foreach_llp (   type,
  it,
  start 
)

#include <include/libwebsockets/lws-dll2.h>

Value:
{ \
type it = &(start); \
while (*(it)) {

lws_start_foreach_llp(): linkedlist pointer iterator helper start

Parameters
typetype of iteration, eg, struct xyz **
ititerator var name to create
startstart of list

This helper creates an iterator and starts a while (it) { loop. The iterator runs through the linked list starting at the address of start and ends when it gets a NULL. The while loop should be terminated using lws_start_foreach_llp().

This helper variant iterates using a pointer to the previous linked-list element. That allows you to easily delete list members by rewriting the previous pointer to the element's next pointer.

Definition at line 116 of file lws-dll2.h.

◆ lws_start_foreach_llp_safe

#define lws_start_foreach_llp_safe (   type,
  it,
  start,
  nxt 
)

#include <include/libwebsockets/lws-dll2.h>

Value:
{ \
type it = &(start); \
type next; \
while (*(it)) { \
next = &((*(it))->nxt); \

Definition at line 121 of file lws-dll2.h.

◆ lws_end_foreach_llp

#define lws_end_foreach_llp (   it,
  nxt 
)

#include <include/libwebsockets/lws-dll2.h>

Value:
it = &(*(it))->nxt; \
} \
}

lws_end_foreach_llp(): linkedlist pointer iterator helper end

Parameters
itsame iterator var name given when starting
nxtmember name in the iterator pointing to next list element

This helper is the partner for lws_start_foreach_llp() that ends the while loop.

Definition at line 138 of file lws-dll2.h.

◆ lws_end_foreach_llp_safe

#define lws_end_foreach_llp_safe (   it)

#include <include/libwebsockets/lws-dll2.h>

Value:
it = next; \
} \
}

Definition at line 143 of file lws-dll2.h.

◆ lws_ll_fwd_insert

#define lws_ll_fwd_insert (   ___new_object,
  ___m_list,
  ___list_head 
)

#include <include/libwebsockets/lws-dll2.h>

Value:
{\
___new_object->___m_list = ___list_head; \
___list_head = ___new_object; \
}

Definition at line 148 of file lws-dll2.h.

◆ lws_ll_fwd_remove

#define lws_ll_fwd_remove (   ___type,
  ___m_list,
  ___target,
  ___list_head 
)

#include <include/libwebsockets/lws-dll2.h>

Value:
{ \
lws_start_foreach_llp(___type **, ___ppss, ___list_head) { \
if (*___ppss == ___target) { \
*___ppss = ___target->___m_list; \
break; \
} \
} lws_end_foreach_llp(___ppss, ___m_list); \
}
#define lws_end_foreach_llp(it, nxt)
Definition: lws-dll2.h:138

Definition at line 157 of file lws-dll2.h.

◆ lws_dll2_search_sz_pl

#define lws_dll2_search_sz_pl (   own,
  name,
  namelen,
  type,
  membd2list,
  membptr 
)

#include <include/libwebsockets/lws-dll2.h>

Value:
((type *)_lws_dll2_search_sz_pl(own, name, namelen, \
offsetof(type, membd2list), \
offsetof(type, membptr)))
LWS_VISIBLE LWS_EXTERN void * _lws_dll2_search_sz_pl(lws_dll2_owner_t *own, const char *name, size_t namelen, size_t dll2_ofs, size_t ptr_ofs)

Definition at line 268 of file lws-dll2.h.

◆ lws_dll2_describe

#define lws_dll2_describe (   x,
 
)

#include <include/libwebsockets/lws-dll2.h>

Definition at line 277 of file lws-dll2.h.

◆ lws_start_foreach_dll_safe

#define lws_start_foreach_dll_safe (   ___type,
  ___it,
  ___tmp,
  ___start 
)

#include <include/libwebsockets/lws-dll2.h>

Value:
{ \
___type ___it = ___start; \
while (___it) { \
___type ___tmp = (___it)->next;

Definition at line 286 of file lws-dll2.h.

◆ lws_end_foreach_dll_safe

#define lws_end_foreach_dll_safe (   ___it,
  ___tmp 
)

#include <include/libwebsockets/lws-dll2.h>

Value:
___it = ___tmp; \
} \
}

Definition at line 292 of file lws-dll2.h.

◆ lws_start_foreach_dll

#define lws_start_foreach_dll (   ___type,
  ___it,
  ___start 
)

#include <include/libwebsockets/lws-dll2.h>

Value:
{ \
___type ___it = ___start; \
while (___it) {

Definition at line 297 of file lws-dll2.h.

◆ lws_end_foreach_dll

#define lws_end_foreach_dll (   ___it)

#include <include/libwebsockets/lws-dll2.h>

Value:
___it = (___it)->next; \
} \
}

Definition at line 302 of file lws-dll2.h.

Typedef Documentation

◆ lws_dll2_t

◆ lws_dll2_owner_t

◆ lws_dll2_foreach_cb_t

typedef int(* lws_dll2_foreach_cb_t) (struct lws_dll2 *d, void *user)

#include <include/libwebsockets/lws-dll2.h>

Definition at line 231 of file lws-dll2.h.

Function Documentation

◆ lws_dll2_is_detached()

LWS_VISIBLE LWS_EXTERN int lws_dll2_is_detached ( const struct lws_dll2 d)

◆ lws_dll2_add_head()

LWS_VISIBLE LWS_EXTERN void lws_dll2_add_head ( struct lws_dll2 d,
struct lws_dll2_owner owner 
)

◆ lws_dll2_add_tail()

LWS_VISIBLE LWS_EXTERN void lws_dll2_add_tail ( struct lws_dll2 d,
struct lws_dll2_owner owner 
)

◆ lws_dll2_remove()

LWS_VISIBLE LWS_EXTERN void lws_dll2_remove ( struct lws_dll2 d)

◆ lws_dll2_foreach_safe()

LWS_VISIBLE LWS_EXTERN int lws_dll2_foreach_safe ( struct lws_dll2_owner owner,
void *  user,
lws_dll2_foreach_cb_t  cb 
)

◆ lws_dll2_clear()

LWS_VISIBLE LWS_EXTERN void lws_dll2_clear ( struct lws_dll2 d)

◆ lws_dll2_owner_clear()

LWS_VISIBLE LWS_EXTERN void lws_dll2_owner_clear ( struct lws_dll2_owner d)

◆ lws_dll2_add_before()

LWS_VISIBLE LWS_EXTERN void lws_dll2_add_before ( struct lws_dll2 d,
struct lws_dll2 after 
)

◆ lws_dll2_add_insert()

LWS_VISIBLE LWS_EXTERN void lws_dll2_add_insert ( struct lws_dll2 d,
struct lws_dll2 prev 
)

◆ lws_dll2_add_sorted()

LWS_VISIBLE LWS_EXTERN void lws_dll2_add_sorted ( lws_dll2_t d,
lws_dll2_owner_t own,
int(*)(const lws_dll2_t *d, const lws_dll2_t *i)  compare 
)

◆ lws_dll2_add_sorted_priv()

LWS_VISIBLE LWS_EXTERN void lws_dll2_add_sorted_priv ( lws_dll2_t d,
lws_dll2_owner_t own,
void *  priv,
int(*)(void *priv, const lws_dll2_t *d, const lws_dll2_t *i)  compare3 
)

◆ _lws_dll2_search_sz_pl()

LWS_VISIBLE LWS_EXTERN void* _lws_dll2_search_sz_pl ( lws_dll2_owner_t own,
const char *  name,
size_t  namelen,
size_t  dll2_ofs,
size_t  ptr_ofs 
)