]> git.sesse.net Git - vlc/commitdiff
Added missing const qualifier to vod_MediaControl.
authorLaurent Aimar <fenrir@videolan.org>
Mon, 26 Feb 2007 19:19:18 +0000 (19:19 +0000)
committerLaurent Aimar <fenrir@videolan.org>
Mon, 26 Feb 2007 19:19:18 +0000 (19:19 +0000)
Improved TAB_* protection and added TAB_INIT/CLEAN.

include/vlc_arrays.h
include/vlc_vod.h

index 7872912b623da297c6c8329d1e3677fc67f1ed2b..f9634984dd19bbf565152b2086719a0c5a09f163 100644 (file)
     }                                                                         \
     while( 0 )
 
+#define TAB_INIT( count, tab )                  \
+  do {                                          \
+    (count) = 0;                                \
+    (tab) = NULL;                               \
+  } while(0)
+
+#define TAB_CLEAN( count, tab )                 \
+  do {                                          \
+    if( tab ) free( tab );                      \
+    (count)= 0;                                 \
+    (tab)= NULL;                                \
+  } while(0)
 
 #define TAB_APPEND( count, tab, p )             \
+  do {                                          \
     if( (count) > 0 )                           \
-    {                                           \
         (tab) = realloc( tab, sizeof( void ** ) * ( (count) + 1 ) ); \
-    }                                           \
     else                                        \
-    {                                           \
         (tab) = malloc( sizeof( void ** ) );    \
-    }                                           \
-    (tab)[count] = (p);        \
-    (count)++
+    (tab)[count] = (p);                         \
+    (count)++;                                  \
+  } while(0)
 
 #define TAB_FIND( count, tab, p, index )        \
-    {                                           \
+  do {                                          \
         int _i_;                                \
         (index) = -1;                           \
         for( _i_ = 0; _i_ < (count); _i_++ )    \
         {                                       \
-            if( (tab)[_i_] == (p) )  \
+            if( (tab)[_i_] == (p) )             \
             {                                   \
                 (index) = _i_;                  \
                 break;                          \
             }                                   \
         }                                       \
-    }
+  } while(0)
 
 #define TAB_REMOVE( count, tab, p )             \
-    {                                           \
+  do {                                          \
         int _i_index_;                          \
         TAB_FIND( count, tab, p, _i_index_ );   \
         if( _i_index_ >= 0 )                    \
         {                                       \
-            if( (count) > 1 )                     \
+            if( (count) > 1 )                   \
             {                                   \
                 memmove( ((void**)(tab) + _i_index_),    \
                          ((void**)(tab) + _i_index_+1),  \
                 (tab) = NULL;                   \
             }                                   \
         }                                       \
-    }
+  } while(0)
 
 /**
  * Binary search in a sorted array. The key must be comparable by < and >
  * \param key value of the key
  * \param answer index of answer within the array. -1 if not found
  */
-#define BSEARCH( entries, count, elem, zetype, key, answer ) {  \
+#define BSEARCH( entries, count, elem, zetype, key, answer ) \
+   do {  \
     int low = 0, high = count - 1;   \
     answer = -1; \
     while( low <= high ) {\
             answer = mid;  break;   \
         }\
     } \
-}
+ } while(0)
 
 /************************************************************************
  * Dictionaries
index fab8bc3a0688aa7a6b877464b2f83df70c26f4ad..2c9e9516de59f9d63b79933d6d3db1d1d78afec8 100644 (file)
@@ -47,7 +47,7 @@ struct vod_t
 };
 
 static inline int vod_MediaControl( vod_t *p_vod, vod_media_t *p_media,
-                                    char *psz_id, int i_query, ... )
+                                    const char *psz_id, int i_query, ... )
 {
     va_list args;
     int i_result;
@@ -63,12 +63,12 @@ static inline int vod_MediaControl( vod_t *p_vod, vod_media_t *p_media,
 
 enum vod_query_e
 {
-    VOD_MEDIA_PLAY,         /* arg1= double *       res=    */
-    VOD_MEDIA_PAUSE,        /* arg1= double *       res=    */
-    VOD_MEDIA_STOP,         /* arg1= double         res=can fail    */
-    VOD_MEDIA_SEEK,         /* arg1= double *       res=    */
-    VOD_MEDIA_REWIND,       /* arg1= double *       res=    */
-    VOD_MEDIA_FORWARD,      /* arg1= double *       res=    */
+    VOD_MEDIA_PLAY,         /* arg1= char *         res=    */
+    VOD_MEDIA_PAUSE,        /* arg1=                res=    */
+    VOD_MEDIA_STOP,         /* arg1=                res=can fail    */
+    VOD_MEDIA_SEEK,         /* arg1= double         res=    */
+    VOD_MEDIA_REWIND,       /* arg1= double         res=    */
+    VOD_MEDIA_FORWARD,      /* arg1= double         res=    */
 };
 
 #endif