[vlc-commits] mkv: removed indirection when initializing std::string
Filip Roséen
git at videolan.org
Sat Mar 5 22:14:46 CET 2016
vlc | branch: master | Filip Roséen <filip at atch.se> | Fri Mar 4 17:04:09 2016 +0100| [881299bec2a9d80536e306c76efc0da2b43a76b9] | committer: Jean-Baptiste Kempf
mkv: removed indirection when initializing std::string
There really is no need to allocate memory for a temporary buffer, copy
the data to this buffer, and then use the buffer to initialize a
std::string, before freeing the buffer.
One of the constructors of std::string can handle the above for us.
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=881299bec2a9d80536e306c76efc0da2b43a76b9
---
modules/demux/mkv/chapter_command.cpp | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/modules/demux/mkv/chapter_command.cpp b/modules/demux/mkv/chapter_command.cpp
index da32529..93403a9 100644
--- a/modules/demux/mkv/chapter_command.cpp
+++ b/modules/demux/mkv/chapter_command.cpp
@@ -706,12 +706,7 @@ bool matroska_script_interpretor_c::Interpret( const binary * p_command, size_t
{
bool b_result = false;
- char *psz_str = static_cast<char*>( malloc( i_size + 1 ) );
- memcpy( psz_str, p_command, i_size );
- psz_str[ i_size ] = '\0';
-
- std::string sz_command = psz_str;
- free( psz_str );
+ std::string sz_command( reinterpret_cast<const char*> (p_command), i_size );
msg_Dbg( &sys.demuxer, "command : %s", sz_command.c_str() );
More information about the vlc-commits
mailing list