Commit 6487b499 authored by Filip Roséen's avatar Filip Roséen Committed by Jean-Baptiste Kempf

mkv: Added reconstruct function to EbmlParser

The two overloads of EbmlParser::reconstruct has been added due to the
fact that there are _a lot_ of places in the code following the below:

    delete ep;
    ep = new EbmlParser (a, b, c, b);

The above will, unless the compiler feels cocky and optimizes it to what
is included in this patch. First free the memory used, and then allocate
new memory for a new EbmlParser.

Instead of doing what is effectively a reallocation, this patch
introduces EbmlParser::reconstruct which will reconstruct the object
in-place (without actually having to reallocate the underlying storage).
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent 1b41c8ea
......@@ -63,6 +63,21 @@ EbmlParser::~EbmlParser( void )
}
}
void EbmlParser::reconstruct( EbmlStream* es, EbmlElement* el_start, demux_t* p_demux )
{
this->reconstruct( es, el_start, p_demux, var_InheritBool( p_demux, "mkv-use-dummy" ) );
}
void EbmlParser::reconstruct( EbmlStream* es, EbmlElement* el_start, demux_t* p_demux,
bool b_with_dummy)
{
this->~EbmlParser();
new( static_cast<void*>( this ) ) EbmlParser(
es, el_start, p_demux, b_with_dummy
);
}
EbmlElement* EbmlParser::UnGet( uint64 i_block_pos, uint64 i_cluster_pos )
{
if ( mi_user_level > mi_level )
......
......@@ -37,6 +37,9 @@ class EbmlParser
bool b_with_dummy );
~EbmlParser( void );
void reconstruct( EbmlStream*, EbmlElement*, demux_t*);
void reconstruct( EbmlStream*, EbmlElement*, demux_t*, bool b_with_dummy );
void Up( void );
void Down( void );
void Reset( demux_t *p_demux );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment