vlc_arrays: split TAB_REMOVE

This commit is contained in:
Francois Cartegnie 2016-02-12 16:17:55 +01:00
parent 92c7785ba9
commit e617042467
1 changed files with 17 additions and 14 deletions

View File

@ -113,25 +113,28 @@ static inline void *realloc_down( void *ptr, size_t size )
} while(0)
#define TAB_ERASE( count, tab, index ) \
do { \
if( (count) > 1 ) \
{ \
memmove( ((void**)(tab) + index), \
((void**)(tab) + index+1), \
( (count) - index - 1 ) * sizeof( *(tab) ) );\
} \
(count)--; \
if( (count) == 0 ) \
{ \
free( tab ); \
(tab) = NULL; \
} \
} 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 ) \
{ \
memmove( ((void**)(tab) + i_index), \
((void**)(tab) + i_index+1), \
( (count) - i_index - 1 ) * sizeof( *(tab) ) );\
} \
(count)--; \
if( (count) == 0 ) \
{ \
free( tab ); \
(tab) = NULL; \
} \
} \
TAB_ERASE( count, tab, i_index ); \
} while(0)
#define TAB_INSERT_CAST( cast, count, tab, p, index ) do { \