} \
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
};
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;
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