[vlc-devel] [PATCH 13/20] mkv: Introduced MKV_CHECKED_PTR_DECL

Filip Roséen filip at videolabs.io
Fri Mar 4 17:04:11 CET 2016


`MKV_IS_ID` is a macro to check whether the object hiding behind a pointer
has a certain dynamic type and it is being used all over the module.

There are however a lot of cases that is followed by a static_cast to the
appropriate type; `MKV_CHECKED_PTR_DECL` has been introduced to shorten
code that has such usage.
---
 modules/demux/mkv/mkv.hpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/modules/demux/mkv/mkv.hpp b/modules/demux/mkv/mkv.hpp
index ed8cc89..ddaa60f 100644
--- a/modules/demux/mkv/mkv.hpp
+++ b/modules/demux/mkv/mkv.hpp
@@ -112,6 +112,7 @@ enum
 #define MKVD_TIMECODESCALE 1000000
 
 #define MKV_IS_ID( el, C ) ( el != NULL && typeid( *el ) == typeid( C ) )
+#define MKV_CHECKED_PTR_DECL( name, type, src ) type * name = MKV_IS_ID(src, type) ? static_cast<type*>(src) : NULL
 
 
 using namespace LIBMATROSKA_NAMESPACE;
-- 
2.7.2



More information about the vlc-devel mailing list