simplified list declaration

This commit is contained in:
Maxim Devaev 2024-03-30 13:07:20 +02:00
parent 70fa6548fe
commit 37f3f093dc
3 changed files with 14 additions and 12 deletions

View File

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

View File

@ -25,9 +25,9 @@
#include <assert.h>
#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; \
} \
}

View File

@ -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 {