From 37f3f093dc42013c37e3001efbafe12e20c2685f Mon Sep 17 00:00:00 2001 From: Maxim Devaev Date: Sat, 30 Mar 2024 13:07:20 +0200 Subject: [PATCH] simplified list declaration --- janus/src/client.h | 4 ++-- src/libs/list.h | 14 ++++++++------ src/ustreamer/http/server.h | 8 ++++---- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/janus/src/client.h b/janus/src/client.h index 34e7131..3e9c438 100644 --- a/janus/src/client.h +++ b/janus/src/client.h @@ -34,7 +34,7 @@ #include "rtp.h" -typedef struct us_janus_client_sx { +typedef struct { janus_callbacks *gw; janus_plugin_session *session; atomic_bool transmit; @@ -48,7 +48,7 @@ typedef struct us_janus_client_sx { us_ring_s *video_ring; us_ring_s *audio_ring; - US_LIST_STRUCT(struct us_janus_client_sx); + US_LIST_DECLARE; } us_janus_client_s; diff --git a/src/libs/list.h b/src/libs/list.h index 5038d8d..adbea76 100644 --- a/src/libs/list.h +++ b/src/libs/list.h @@ -25,9 +25,9 @@ #include -#define US_LIST_STRUCT(...) \ - __VA_ARGS__ *prev; \ - __VA_ARGS__ *next; +#define US_LIST_DECLARE \ + void *prev; \ + void *next; #define US_LIST_ITERATE(x_first, x_item, ...) { \ for (__typeof__(x_first) x_item = x_first; x_item;) { \ @@ -42,7 +42,7 @@ x_first = x_item; \ } else { \ __typeof__(x_first) m_last = x_first; \ - for (; m_last->next; m_last = m_last->next); \ + for (; m_last->next != NULL; m_last = m_last->next); \ x_item->prev = m_last; \ m_last->next = x_item; \ } \ @@ -57,10 +57,12 @@ if (x_item->prev == NULL) { \ x_first = x_item->next; \ } else { \ - x_item->prev->next = x_item->next; \ + __typeof__(x_first) m_prev = x_item->prev; \ + m_prev->next = x_item->next; \ } \ if (x_item->next != NULL) { \ - x_item->next->prev = x_item->prev; \ + __typeof__(x_first) m_next = x_item->next; \ + m_next->prev = x_item->prev; \ } \ } diff --git a/src/ustreamer/http/server.h b/src/ustreamer/http/server.h index 1907aad..b8c524b 100644 --- a/src/ustreamer/http/server.h +++ b/src/ustreamer/http/server.h @@ -36,7 +36,7 @@ #include "../stream.h" -typedef struct us_stream_client_sx { +typedef struct { struct us_server_sx *server; struct evhttp_request *request; @@ -54,15 +54,15 @@ typedef struct us_stream_client_sx { us_fps_s *fps; - US_LIST_STRUCT(struct us_stream_client_sx); + US_LIST_DECLARE; } us_stream_client_s; -typedef struct us_snapshot_client_sx { +typedef struct { struct us_server_sx *server; struct evhttp_request *request; ldf request_ts; - US_LIST_STRUCT(struct us_snapshot_client_sx); + US_LIST_DECLARE; } us_snapshot_client_s; typedef struct {