]> git.sesse.net Git - vlc/blobdiff - include/vlc_arrays.h
Added a c++ compatible TAB_APPEND_CPP
[vlc] / include / vlc_arrays.h
index f9634984dd19bbf565152b2086719a0c5a09f163..11a8de8fa6c93baf0196c38c9715a2567361684c 100644 (file)
     (tab)= NULL;                                \
   } while(0)
 
-#define TAB_APPEND( count, tab, p )             \
+#define TAB_APPEND_CAST( cast, count, tab, p )             \
   do {                                          \
     if( (count) > 0 )                           \
-        (tab) = realloc( tab, sizeof( void ** ) * ( (count) + 1 ) ); \
+        (tab) = cast realloc( tab, sizeof( void ** ) * ( (count) + 1 ) ); \
     else                                        \
-        (tab) = malloc( sizeof( void ** ) );    \
+        (tab) = cast malloc( sizeof( void ** ) );    \
     (tab)[count] = (p);                         \
     (count)++;                                  \
   } while(0)
 
+#define TAB_APPEND( count, tab, p )             \
+    TAB_APPEND_CAST( , count, tab, p )
+#define TAB_APPEND_CPP( type, count, tab, p )   \
+    TAB_APPEND_CAST( (type**), count, tab, p )
+
 #define TAB_FIND( count, tab, p, index )        \
   do {                                          \
         int _i_;                                \