1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

lws_dll_foreach_safe

This commit is contained in:
Andy Green 2019-03-18 16:12:45 +08:00
parent 30eb3e94ab
commit 8dd3383368
2 changed files with 16 additions and 0 deletions

View file

@ -187,6 +187,11 @@ lws_dll_add_front(struct lws_dll *d, struct lws_dll *phead);
LWS_VISIBLE LWS_EXTERN void
lws_dll_remove(struct lws_dll *d);
/* another way to do lws_start_foreach_dll_safe() on a list via a cb */
LWS_VISIBLE LWS_EXTERN int
lws_dll_foreach_safe(struct lws_dll *phead, int (*cb)(struct lws_dll *d));
struct lws_dll_lws { /* typed as struct lws * */
struct lws_dll_lws *prev;
struct lws_dll_lws *next;

View file

@ -138,6 +138,17 @@ lws_dll_remove(struct lws_dll *d)
d->next = NULL;
}
int
lws_dll_foreach_safe(struct lws_dll *phead, int (*cb)(struct lws_dll *d))
{
lws_start_foreach_dll_safe(struct lws_dll *, p, tp, phead->next) {
if (cb(p))
return 1;
} lws_end_foreach_dll_safe(p, tp);
return 0;
}
#if !(defined(LWS_PLAT_OPTEE) && !defined(LWS_WITH_NETWORK))
LWS_VISIBLE lws_usec_t