[vlc-devel] [PATCH 6/7] demux:mkv: pass the list of matroska_segment_c by reference, not pointers

Steve Lhomme robux4 at videolabs.io
Tue Mar 15 08:50:24 CET 2016


---
 modules/demux/mkv/demux.cpp           |  2 +-
 modules/demux/mkv/virtual_segment.cpp | 20 ++++++++++----------
 modules/demux/mkv/virtual_segment.hpp |  6 +++---
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/modules/demux/mkv/demux.cpp b/modules/demux/mkv/demux.cpp
index f2eed13..5018439 100644
--- a/modules/demux/mkv/demux.cpp
+++ b/modules/demux/mkv/demux.cpp
@@ -761,7 +761,7 @@ virtual_segment_c *demux_sys_t::VirtualFromSegments( std::vector<matroska_segmen
 {
     if ( p_segments->empty() )
         return NULL;
-    virtual_segment_c *p_result = new virtual_segment_c( p_segments );
+    virtual_segment_c *p_result = new virtual_segment_c( *p_segments );
     return p_result;
 }
 
diff --git a/modules/demux/mkv/virtual_segment.cpp b/modules/demux/mkv/virtual_segment.cpp
index 3653371..007c7db 100644
--- a/modules/demux/mkv/virtual_segment.cpp
+++ b/modules/demux/mkv/virtual_segment.cpp
@@ -28,20 +28,20 @@
 #include "demux.hpp"
 
 /* FIXME move this */
-matroska_segment_c * getSegmentbyUID( KaxSegmentUID * p_uid, std::vector<matroska_segment_c*> *segments )
+matroska_segment_c * getSegmentbyUID( KaxSegmentUID * p_uid, std::vector<matroska_segment_c*> & segments )
 {
-    for( size_t i = 0; i < (*segments).size(); i++ )
+    for( size_t i = 0; i < segments.size(); i++ )
     {
-        if( (*segments)[i]->p_segment_uid &&
-            *p_uid == *((*segments)[i]->p_segment_uid) )
-            return (*segments)[i];
+        if( segments[i]->p_segment_uid &&
+            *p_uid == *(segments[i]->p_segment_uid) )
+            return segments[i];
     }
     return NULL;
 }
 
 virtual_chapter_c * virtual_chapter_c::CreateVirtualChapter( chapter_item_c * p_chap,
                                                              matroska_segment_c * p_main_segment,
-                                                             std::vector<matroska_segment_c*> * segments,
+                                                             std::vector<matroska_segment_c*> & segments,
                                                              int64_t * usertime_offset, bool b_ordered)
 {
     matroska_segment_c * p_segment = p_main_segment;
@@ -102,10 +102,10 @@ virtual_chapter_c::~virtual_chapter_c()
 }
 
 
-virtual_edition_c::virtual_edition_c( chapter_edition_c * p_edit, std::vector<matroska_segment_c*> *opened_segments)
+virtual_edition_c::virtual_edition_c( chapter_edition_c * p_edit, std::vector<matroska_segment_c*> & opened_segments)
 {
     bool b_fake_ordered = false;
-    matroska_segment_c *p_main_segment = (*opened_segments)[0];
+    matroska_segment_c *p_main_segment = opened_segments[0];
     p_edition = p_edit;
     b_ordered = false;
 
@@ -259,11 +259,11 @@ void virtual_edition_c::retimeChapters()
     }
 }
 
-virtual_segment_c::virtual_segment_c( std::vector<matroska_segment_c*> * p_opened_segments )
+virtual_segment_c::virtual_segment_c( std::vector<matroska_segment_c*> & p_opened_segments )
 {
     /* Main segment */
     std::vector<chapter_edition_c*>::size_type i;
-    matroska_segment_c *p_segment = (*p_opened_segments)[0];
+    matroska_segment_c *p_segment = p_opened_segments[0];
     i_sys_title = 0;
     p_current_chapter = NULL;
     b_current_chapter_entered = false;
diff --git a/modules/demux/mkv/virtual_segment.hpp b/modules/demux/mkv/virtual_segment.hpp
index 4d5b942..0e08d4f 100644
--- a/modules/demux/mkv/virtual_segment.hpp
+++ b/modules/demux/mkv/virtual_segment.hpp
@@ -44,7 +44,7 @@ public:
 
     static virtual_chapter_c * CreateVirtualChapter( chapter_item_c * p_chap,
                                                      matroska_segment_c * p_main_segment,
-                                                     std::vector<matroska_segment_c*> * segments,
+                                                     std::vector<matroska_segment_c*> & segments,
                                                      int64_t * usertime_offset, bool b_ordered );
 
     virtual_chapter_c* getSubChapterbyTimecode( int64_t time );
@@ -80,7 +80,7 @@ public:
 class virtual_edition_c
 {
 public:
-    virtual_edition_c( chapter_edition_c * p_edition, std::vector<matroska_segment_c*> *opened_segments );
+    virtual_edition_c( chapter_edition_c * p_edition, std::vector<matroska_segment_c*> & opened_segments );
     ~virtual_edition_c();
     std::vector<virtual_chapter_c*> chapters;
 
@@ -111,7 +111,7 @@ private:
 class virtual_segment_c
 {
 public:
-    virtual_segment_c( std::vector<matroska_segment_c*> * opened_segments );
+    virtual_segment_c( std::vector<matroska_segment_c*> & opened_segments );
     ~virtual_segment_c();
     std::vector<virtual_edition_c*> editions;
     std::vector<virtual_edition_c*>::size_type i_current_edition;
-- 
2.7.2.windows.1



More information about the vlc-devel mailing list