[vlc-commits] [Git][videolan/vlc][master] stream: use container_of

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Thu Apr 28 16:54:24 UTC 2022



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
3d2f691e by Thomas Guillem at 2022-04-28T16:30:00+00:00
stream: use container_of

- - - - -


1 changed file:

- src/input/stream.c


Changes:

=====================================
src/input/stream.c
=====================================
@@ -106,9 +106,11 @@ stream_t *vlc_stream_CustomNew(vlc_object_t *parent,
     return &priv->stream;
 }
 
+#define stream_priv(s) container_of(s, stream_priv_t, stream)
+
 void *vlc_stream_Private(stream_t *stream)
 {
-    return ((stream_priv_t *)stream)->private_data;
+    return stream_priv(stream)->private_data;
 }
 
 stream_t *vlc_stream_CommonNew(vlc_object_t *parent,
@@ -119,7 +121,7 @@ stream_t *vlc_stream_CommonNew(vlc_object_t *parent,
 
 void stream_CommonDelete(stream_t *s)
 {
-    stream_priv_t *priv = (stream_priv_t *)s;
+    stream_priv_t *priv = stream_priv(s);
 
     if (priv->text.conv != (vlc_iconv_t)(-1))
         vlc_iconv_close(priv->text.conv);
@@ -138,7 +140,7 @@ void stream_CommonDelete(stream_t *s)
  */
 void vlc_stream_Delete(stream_t *s)
 {
-    stream_priv_t *priv = (stream_priv_t *)s;
+    stream_priv_t *priv = stream_priv(s);
 
     priv->destroy(s);
     stream_CommonDelete(s);
@@ -192,7 +194,7 @@ stream_t *(vlc_stream_NewMRL)(vlc_object_t* parent, const char* mrl )
 #define STREAM_LINE_MAX (2048*100)
 char *vlc_stream_ReadLine( stream_t *s )
 {
-    stream_priv_t *priv = (stream_priv_t *)s;
+    stream_priv_t *priv = stream_priv(s);
 
     /* Let's fail quickly if this is a readdir access */
     if( s->pf_read == NULL && s->pf_block == NULL )
@@ -424,7 +426,7 @@ static ssize_t vlc_stream_CopyBlock(block_t **restrict pp,
 
 static ssize_t vlc_stream_ReadRaw(stream_t *s, void *buf, size_t len)
 {
-    stream_priv_t *priv = (stream_priv_t *)s;
+    stream_priv_t *priv = stream_priv(s);
     ssize_t ret;
 
     assert(len <= SSIZE_MAX);
@@ -468,7 +470,7 @@ static ssize_t vlc_stream_ReadRaw(stream_t *s, void *buf, size_t len)
 
 ssize_t vlc_stream_ReadPartial(stream_t *s, void *buf, size_t len)
 {
-    stream_priv_t *priv = (stream_priv_t *)s;
+    stream_priv_t *priv = stream_priv(s);
     ssize_t ret;
 
     ret = vlc_stream_CopyBlock(&priv->peek, buf, len);
@@ -512,7 +514,7 @@ ssize_t vlc_stream_Read(stream_t *s, void *buf, size_t len)
 
 ssize_t vlc_stream_Peek(stream_t *s, const uint8_t **restrict bufp, size_t len)
 {
-    stream_priv_t *priv = (stream_priv_t *)s;
+    stream_priv_t *priv = stream_priv(s);
     block_t *peek;
 
     peek = priv->peek;
@@ -566,7 +568,7 @@ ssize_t vlc_stream_Peek(stream_t *s, const uint8_t **restrict bufp, size_t len)
 
 block_t *vlc_stream_ReadBlock(stream_t *s)
 {
-    stream_priv_t *priv = (stream_priv_t *)s;
+    stream_priv_t *priv = stream_priv(s);
     block_t *block;
 
     if (vlc_killed())
@@ -616,21 +618,21 @@ block_t *vlc_stream_ReadBlock(stream_t *s)
 
 uint64_t vlc_stream_Tell(const stream_t *s)
 {
-    const stream_priv_t *priv = (const stream_priv_t *)s;
+    const stream_priv_t *priv = stream_priv(s);
 
     return priv->offset;
 }
 
 bool vlc_stream_Eof(const stream_t *s)
 {
-    const stream_priv_t *priv = (const stream_priv_t *)s;
+    const stream_priv_t *priv = stream_priv(s);
 
     return priv->eof;
 }
 
 int vlc_stream_Seek(stream_t *s, uint64_t offset)
 {
-    stream_priv_t *priv = (stream_priv_t *)s;
+    stream_priv_t *priv = stream_priv(s);
 
     priv->eof = false;
 
@@ -692,7 +694,7 @@ int vlc_stream_Seek(stream_t *s, uint64_t offset)
  */
 int vlc_stream_vaControl(stream_t *s, int cmd, va_list args)
 {
-    stream_priv_t *priv = (stream_priv_t *)s;
+    stream_priv_t *priv = stream_priv(s);
 
     switch (cmd)
     {



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/3d2f691ebc4cf484a5eaa4882c790148f5ae8095

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/3d2f691ebc4cf484a5eaa4882c790148f5ae8095
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list