[vlc-commits] vlc_arrays: split TAB_REMOVE

Francois Cartegnie git at videolan.org
Sat Feb 13 15:44:06 CET 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Feb 12 16:17:55 2016 +0100| [e6170424672b00a70864cfc88e8b2c863771066c] | committer: Francois Cartegnie

vlc_arrays: split TAB_REMOVE

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e6170424672b00a70864cfc88e8b2c863771066c
---

 include/vlc_arrays.h |   31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/include/vlc_arrays.h b/include/vlc_arrays.h
index 91f5405..886a7f9 100644
--- a/include/vlc_arrays.h
+++ b/include/vlc_arrays.h
@@ -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 { \



More information about the vlc-commits mailing list