[vlc-devel] [PATCH 01/21] input/stream: stream-fragments: add data-members to struct stream_priv_t

Filip Roséen filip at atch.se
Sun Jul 31 22:42:10 CEST 2016


The relevant data-members that this commit adds will be used by the
stream-fragment implementation to keep track of its state.

This commit also introduce initialization as well as clean-up for the
data-members affected.
---
 src/input/stream.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/src/input/stream.c b/src/input/stream.c
index 6c614f8..a16c675 100644
--- a/src/input/stream.c
+++ b/src/input/stream.c
@@ -56,6 +56,27 @@ typedef struct stream_priv_t
         unsigned char char_width;
         bool          little_endian;
     } text;
+
+    /**
+     * \defgroup stream_fragments_internals Internals
+     * \internal
+     * @{
+     *   \ingroup stream_fragments
+     **/
+    struct {
+        size_t tokens; /**< the number of entries in stream_priv_t::data */
+        size_t offset; /**< index of next unhandled fragment in stream_priv_t::data */
+        char**   data; /**<
+              * Unhandled fragments shall be stored within this member starting
+              * at index `stream_priv_t::offset`. The entry at
+              * `stream_priv_t::offset-1` shall contain the MRL where the entry
+              * at `stream_priv_t::offset` is a secondary-resource.
+              **/
+    } fragments;
+    /**
+     * @}
+     **/
+
 } stream_priv_t;
 
 /**
@@ -92,6 +113,10 @@ stream_t *vlc_stream_CommonNew(vlc_object_t *parent,
     priv->text.char_width = 1;
     priv->text.little_endian = false;
 
+    priv->fragments.tokens = 0;
+    priv->fragments.offset = 0;
+    priv->fragments.data = NULL;
+
     return s;
 }
 
@@ -108,6 +133,12 @@ void stream_CommonDelete(stream_t *s)
         block_Release(priv->block);
 
     free(s->psz_url);
+
+    for( size_t i = 0; i < priv->fragments.tokens; ++i )
+        free( priv->fragments.data[i] );
+
+    TAB_CLEAN( priv->fragments.tokens, priv->fragments.data );
+
     vlc_object_release(s);
 }
 
-- 
2.9.2



More information about the vlc-devel mailing list