[vlc-commits] arrays: fix bogus cast in TAB_INSERT and TAB_ERASE

Rémi Denis-Courmont git at videolan.org
Tue Feb 21 21:02:50 CET 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Feb 21 21:53:15 2017 +0200| [b866f51909919cea3d99f399c92fe4cd84c4d0c0] | committer: Rémi Denis-Courmont

arrays: fix bogus cast in TAB_INSERT and TAB_ERASE

The cast, which is from the original stream output chain mega-patch,
assumed that all pointer types have same representation - which is
usually true. But it also assumed that tables would only contain
pointers; this might have been true back then, but it no longer is.

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

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

diff --git a/include/vlc_arrays.h b/include/vlc_arrays.h
index 78b0f54..c94e1de 100644
--- a/include/vlc_arrays.h
+++ b/include/vlc_arrays.h
@@ -116,11 +116,9 @@ static inline void *realloc_down( void *ptr, size_t size )
 #define TAB_ERASE( count, tab, index )      \
   do {                                      \
         if( (count) > 1 )                   \
-        {                                   \
-            memmove( ((void**)(tab) + index),    \
-                     ((void**)(tab) + index+1),  \
-                     ( (count) - index - 1 ) * sizeof( *(tab) ) );\
-        }                                   \
+            memmove( (tab) + (index),       \
+                     (tab) + (index) + 1,   \
+                     ((count) - (index) - 1 ) * sizeof( *(tab) ) );\
         (count)--;                          \
         if( (count) == 0 )                  \
         {                                   \
@@ -144,9 +142,9 @@ static inline void *realloc_down( void *ptr, size_t size )
         (tab) = cast malloc( sizeof( *(tab) ) );       \
     if( !(tab) ) abort();                       \
     if( (count) - (index) > 0 )                 \
-        memmove( (void**)(tab) + (index) + 1,   \
-                 (void**)(tab) + (index),       \
-                 ((count) - (index)) * sizeof(*(tab)) );\
+        memmove( (tab) + (index) + 1,           \
+                 (tab) + (index),               \
+                 ((count) - (index)) * sizeof( *(tab) ) );\
     (tab)[(index)] = (p);                       \
     (count)++;                                  \
 } while(0)



More information about the vlc-commits mailing list