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

Macro Definition Documentation

◆ 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_end_foreach_dll

#define lws_end_foreach_dll (   ___it)

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

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

◆ lws_end_foreach_dll_safe

#define lws_end_foreach_dll_safe (   ___it,
  ___tmp 
)

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

Value:
___it = ___tmp; \
} \
}

◆ 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.

◆ 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.

◆ 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.

◆ lws_end_foreach_llp_safe

#define lws_end_foreach_llp_safe (   it)

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

Value:
it = next; \
} \
}

◆ 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; \
}

◆ 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

◆ lws_start_foreach_dll

#define lws_start_foreach_dll (   ___type,
  ___it,
  ___start 
)

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

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

◆ 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;

◆ 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().

◆ 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.

◆ 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.

◆ 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); \