libwebsockets
Lightweight C library for HTML5 websockets
Loading...
Searching...
No Matches
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_ARM_TOTAL_BAN   1
#define lws_dll2_search_sz_pl(own, name, namelen, type, membd2list, membptr)
#define lws_dll2_owner_container(___d, ___type, ___membowner)
#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)
#define lws_start_foreach_dll_back(___type, ___it, ___start)
#define lws_end_foreach_dll_back(___it)
#define lws_start_foreach_dll_safe_back(___type, ___it, ___tmp, ___start)
#define lws_end_foreach_dll_safe_back(___it, ___tmp)

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 int lws_dll2_is_in_list (struct lws_dll2_owner *owner, struct lws_dll2 *d)
LWS_VISIBLE LWS_EXTERN struct lws_dll2_lws_dll2_safe_next (struct lws_dll2_owner *ow, uint32_t *gen, struct lws_dll2 *cand)
LWS_VISIBLE LWS_EXTERN struct lws_dll2_lws_dll2_safe_prev (struct lws_dll2_owner *ow, uint32_t *gen, struct lws_dll2 *cand)
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)

Variables

LWS_VISIBLE LWS_EXTERN_FOR_DATA int lws_dll2_guard_quiet

Detailed Description

Linked list apis

simple single and doubly-linked lists


Data Structure Documentation

◆ lws_dll2

struct lws_dll2

Definition at line 289 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 295 of file lws-dll2.h.

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

Macro Definition Documentation

◆ lws_start_foreach_ll

#define lws_start_foreach_ll ( type,
it,
start )

#include <lws-dll2.h>

Value:
{ \
type it = start; \
while (it) { \
int _c_##it = 0, _b_##it = 0; \
for (; !_c_##it; _c_##it = 1) {

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

Note: Thanks to the structural abstraction, you can now safely use continue; or break; to control the loop as if it were a standard for / while loop.

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

48#define lws_start_foreach_ll(type, it, start)\
49{ \
50 type it = start; \
51 while (it) { \
52 int _c_##it = 0, _b_##it = 0; \
53 for (; !_c_##it; _c_##it = 1) {

◆ lws_end_foreach_ll

#define lws_end_foreach_ll ( it,
nxt )

#include <lws-dll2.h>

Value:
_b_##it = 1; \
} \
if (!_b_##it) break; \
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.

Note: Thanks to the structural abstraction, you can now safely use continue; or break; to control the loop as if it were a standard for / while loop.

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

69#define lws_end_foreach_ll(it, nxt) \
70 _b_##it = 1; \
71 } \
72 if (!_b_##it) break; \
73 it = it->nxt; \
74 } \
75}

◆ lws_start_foreach_ll_safe

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

#include <lws-dll2.h>

Value:
{ \
type next_##it; \
for (type it = start; it && ((next_##it = it->nxt), 1); it = next_##it) {

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.

Note: Thanks to the structural abstraction, you can now safely use continue; or break; to control the loop as if it were a standard for / while loop.

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

96#define lws_start_foreach_ll_safe(type, it, start, nxt)\
97{ \
98 type next_##it; \
99 for (type it = start; it && ((next_##it = it->nxt), 1); it = next_##it) {

◆ lws_end_foreach_ll_safe

#define lws_end_foreach_ll_safe ( it)

#include <lws-dll2.h>

Value:
} \
}

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.

Note: Thanks to the structural abstraction, you can now safely use continue; or break; to control the loop as if it were a standard for / while loop.

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

115#define lws_end_foreach_ll_safe(it) \
116 } \
117}

◆ lws_start_foreach_llp

#define lws_start_foreach_llp ( type,
it,
start )

#include <lws-dll2.h>

Value:
{ \
type it = &(start); \
while (*(it)) { \
int _c_##it = 0, _b_##it = 0; \
for (; !_c_##it; _c_##it = 1) {

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.

Note: Thanks to the structural abstraction, you can now safely use continue; or break; to control the loop as if it were a standard for / while loop.

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

139#define lws_start_foreach_llp(type, it, start)\
140{ \
141 type it = &(start); \
142 while (*(it)) { \
143 int _c_##it = 0, _b_##it = 0; \
144 for (; !_c_##it; _c_##it = 1) {

◆ lws_start_foreach_llp_safe

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

#include <lws-dll2.h>

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

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

146#define lws_start_foreach_llp_safe(type, it, start, nxt)\
147{ \
148 type next; \
149 for (type it = &(start); *(it) && ((next = &((*(it))->nxt)), 1); it = next) {

◆ lws_end_foreach_llp

#define lws_end_foreach_llp ( it,
nxt )

#include <lws-dll2.h>

Value:
_b_##it = 1; \
} \
if (!_b_##it) break; \
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.

Note: Thanks to the structural abstraction, you can now safely use continue; or break; to control the loop as if it were a standard for / while loop.

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

165#define lws_end_foreach_llp(it, nxt) \
166 _b_##it = 1; \
167 } \
168 if (!_b_##it) break; \
169 it = &(*(it))->nxt; \
170 } \
171}

◆ lws_end_foreach_llp_safe

#define lws_end_foreach_llp_safe ( it)

#include <lws-dll2.h>

Value:
} \
}

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

173#define lws_end_foreach_llp_safe(it) \
174 } \
175}

◆ lws_ll_fwd_insert

#define lws_ll_fwd_insert ( ___new_object,
___m_list,
___list_head )

#include <lws-dll2.h>

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

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

◆ lws_ll_fwd_remove

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

#include <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:165

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

◆ LWS_DLL2_ARM_TOTAL_BAN

#define LWS_DLL2_ARM_TOTAL_BAN   1

#include <lws-dll2.h>

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

◆ lws_dll2_search_sz_pl

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

#include <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 450 of file lws-dll2.h.

450#define lws_dll2_search_sz_pl(own, name, namelen, type, membd2list, membptr) \
451 ((type *)_lws_dll2_search_sz_pl(own, name, namelen, \
452 offsetof(type, membd2list), \
453 offsetof(type, membptr)))

◆ lws_dll2_owner_container

#define lws_dll2_owner_container ( ___d,
___type,
___membowner )

#include <lws-dll2.h>

Value:
((___type *)_lws_dll2_owner_container(___d, \
offsetof(___type, ___membowner)))

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

476#define lws_dll2_owner_container(___d, ___type, ___membowner) \
477 ((___type *)_lws_dll2_owner_container(___d, \
478 offsetof(___type, ___membowner)))

◆ lws_dll2_describe

#define lws_dll2_describe ( x,
y )

#include <lws-dll2.h>

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

◆ lws_start_foreach_dll_safe

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

#include <lws-dll2.h>

Value:
{ \
___type ___tmp; \
struct lws_dll2 *___st_##___it = (___start); \
struct lws_dll2_owner *___ow_##___it = \
___st_##___it ? ___st_##___it->owner : NULL; \
uint32_t ___gen_##___it = ___ow_##___it ? \
___ow_##___it->generation : 0; \
for (___type ___it = ___st_##___it; \
___it && (((___tmp) = (___it)->next), 1); \
___it = _lws_dll2_safe_next(___ow_##___it, &___gen_##___it, \
___tmp)) {
LWS_VISIBLE LWS_EXTERN struct lws_dll2 * _lws_dll2_safe_next(struct lws_dll2_owner *ow, uint32_t *gen, struct lws_dll2 *cand)
unsigned int uint32_t

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

509#define lws_start_foreach_dll_safe(___type, ___it, ___tmp, ___start) \
510{ \
511 ___type ___tmp; \
512 struct lws_dll2 *___st_##___it = (___start); \
513 struct lws_dll2_owner *___ow_##___it = \
514 ___st_##___it ? ___st_##___it->owner : NULL; \
515 uint32_t ___gen_##___it = ___ow_##___it ? \
516 ___ow_##___it->generation : 0; \
517 for (___type ___it = ___st_##___it; \
518 ___it && (((___tmp) = (___it)->next), 1); \
519 ___it = _lws_dll2_safe_next(___ow_##___it, &___gen_##___it, \
520 ___tmp)) {

◆ lws_end_foreach_dll_safe

#define lws_end_foreach_dll_safe ( ___it,
___tmp )

#include <lws-dll2.h>

Value:
} \
}

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

522#define lws_end_foreach_dll_safe(___it, ___tmp) \
523 } \
524}

◆ lws_start_foreach_dll

#define lws_start_foreach_dll ( ___type,
___it,
___start )

#include <lws-dll2.h>

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

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

526#define lws_start_foreach_dll(___type, ___it, ___start) \
527{ \
528 for (___type ___it = (___start); ___it; ___it = (___it)->next) {

◆ lws_end_foreach_dll

#define lws_end_foreach_dll ( ___it)

#include <lws-dll2.h>

Value:
} \
}

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

530#define lws_end_foreach_dll(___it) \
531 } \
532}

◆ lws_start_foreach_dll_back

#define lws_start_foreach_dll_back ( ___type,
___it,
___start )

#include <lws-dll2.h>

Value:
{ \
for (___type ___it = (___start); ___it; ___it = (___it)->prev) {

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

542#define lws_start_foreach_dll_back(___type, ___it, ___start) \
543{ \
544 for (___type ___it = (___start); ___it; ___it = (___it)->prev) {

◆ lws_end_foreach_dll_back

#define lws_end_foreach_dll_back ( ___it)

#include <lws-dll2.h>

Value:
} \
}

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

546#define lws_end_foreach_dll_back(___it) \
547 } \
548}

◆ lws_start_foreach_dll_safe_back

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

#include <lws-dll2.h>

Value:
{ \
___type ___tmp; \
struct lws_dll2 *___st_##___it = (___start); \
struct lws_dll2_owner *___ow_##___it = \
___st_##___it ? ___st_##___it->owner : NULL; \
uint32_t ___gen_##___it = ___ow_##___it ? \
___ow_##___it->generation : 0; \
for (___type ___it = ___st_##___it; \
___it && (((___tmp) = (___it)->prev), 1); \
___it = _lws_dll2_safe_prev(___ow_##___it, &___gen_##___it, \
___tmp)) {
LWS_VISIBLE LWS_EXTERN struct lws_dll2 * _lws_dll2_safe_prev(struct lws_dll2_owner *ow, uint32_t *gen, struct lws_dll2 *cand)

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

563#define lws_start_foreach_dll_safe_back(___type, ___it, ___tmp, ___start) \
564{ \
565 ___type ___tmp; \
566 struct lws_dll2 *___st_##___it = (___start); \
567 struct lws_dll2_owner *___ow_##___it = \
568 ___st_##___it ? ___st_##___it->owner : NULL; \
569 uint32_t ___gen_##___it = ___ow_##___it ? \
570 ___ow_##___it->generation : 0; \
571 for (___type ___it = ___st_##___it; \
572 ___it && (((___tmp) = (___it)->prev), 1); \
573 ___it = _lws_dll2_safe_prev(___ow_##___it, &___gen_##___it, \
574 ___tmp)) {

◆ lws_end_foreach_dll_safe_back

#define lws_end_foreach_dll_safe_back ( ___it,
___tmp )

#include <lws-dll2.h>

Value:
} \
}

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

576#define lws_end_foreach_dll_safe_back(___it, ___tmp) \
577 } \
578}

Typedef Documentation

◆ lws_dll2_t

typedef struct lws_dll2 lws_dll2_t

#include <lws-dll2.h>

◆ lws_dll2_owner_t

#include <lws-dll2.h>

◆ lws_dll2_foreach_cb_t

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

#include <lws-dll2.h>

Definition at line 363 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)

#include <lws-dll2.h>

References LWS_INLINE.

◆ lws_dll2_add_head()

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

#include <lws-dll2.h>

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_dll2_add_tail()

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

#include <lws-dll2.h>

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_dll2_remove()

LWS_VISIBLE LWS_EXTERN void lws_dll2_remove ( struct lws_dll2 * d)

#include <lws-dll2.h>

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

#include <lws-dll2.h>

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_dll2_clear()

LWS_VISIBLE LWS_EXTERN void lws_dll2_clear ( struct lws_dll2 * d)

#include <lws-dll2.h>

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_dll2_owner_clear()

LWS_VISIBLE LWS_EXTERN void lws_dll2_owner_clear ( struct lws_dll2_owner * d)

#include <lws-dll2.h>

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_dll2_add_before()

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

#include <lws-dll2.h>

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_dll2_add_insert()

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

#include <lws-dll2.h>

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_dll2_add_sorted()

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

#include <lws-dll2.h>

References LWS_EXTERN, and LWS_VISIBLE.

◆ 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(* compare3 )(void *priv, const lws_dll2_t *d, const lws_dll2_t *i) )

#include <lws-dll2.h>

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_dll2_is_in_list()

LWS_VISIBLE LWS_EXTERN int lws_dll2_is_in_list ( struct lws_dll2_owner * owner,
struct lws_dll2 * d )

#include <lws-dll2.h>

References LWS_EXTERN, and LWS_VISIBLE.

◆ _lws_dll2_safe_next()

LWS_VISIBLE LWS_EXTERN struct lws_dll2 * _lws_dll2_safe_next ( struct lws_dll2_owner * ow,
uint32_t * gen,
struct lws_dll2 * cand )

#include <lws-dll2.h>

References LWS_EXTERN, and LWS_VISIBLE.

◆ _lws_dll2_safe_prev()

LWS_VISIBLE LWS_EXTERN struct lws_dll2 * _lws_dll2_safe_prev ( struct lws_dll2_owner * ow,
uint32_t * gen,
struct lws_dll2 * cand )

#include <lws-dll2.h>

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

#include <lws-dll2.h>

Variable Documentation

◆ lws_dll2_guard_quiet

LWS_VISIBLE LWS_EXTERN_FOR_DATA int lws_dll2_guard_quiet

#include <lws-dll2.h>

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