[vlc-devel] [PATCH 09/14] mkv: removed unnecessary dynamic allocation

Filip Roséen filip at videolabs.io
Wed Mar 9 12:50:04 CET 2016


Replaced the dynamic allocation with an equivalent construction on the
stack (we do not need dynamic life time since it is unconditionally
destroyed at the end of the block).
---
 modules/demux/mkv/matroska_segment.cpp | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/modules/demux/mkv/matroska_segment.cpp b/modules/demux/mkv/matroska_segment.cpp
index 568e1f8..d04a7a5 100644
--- a/modules/demux/mkv/matroska_segment.cpp
+++ b/modules/demux/mkv/matroska_segment.cpp
@@ -1064,22 +1064,19 @@ void matroska_segment_c::EnsureDuration()
     // find the last Cluster manually
     if ( !i_last_cluster_pos && cluster != NULL )
     {
-        EbmlElement *el;
-        EbmlParser *ep;
-
         es.I_O().setFilePointer( cluster->GetElementPosition(), seek_beginning );
-        ep = new EbmlParser( &es , segment, &sys.demuxer,
+
+        EbmlElement* el;
+        EbmlParser ep( &es, segment, &sys.demuxer,
                              var_InheritBool( &sys.demuxer, "mkv-use-dummy" ) );
 
-        while( ( el = ep->Get() ) != NULL )
+        while( ( el = ep.Get() ) != NULL )
         {
             if ( MKV_IS_ID( el, KaxCluster ) )
             {
                 i_last_cluster_pos = el->GetElementPosition();
             }
         }
-
-        delete ep;
     }
 
     // find the last timecode in the Cluster
-- 
2.7.2



More information about the vlc-devel mailing list