vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Wed Feb  6 
20:56:02 2013 +0200| [aba4767f273048deca4c17d712bec3da9bf362d8] | committer: 
Rémi Denis-Courmont

TAB_FIND/TAB_REMOVE: remove inner variable, improve expansion safety

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

 include/vlc_arrays.h |   12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/include/vlc_arrays.h b/include/vlc_arrays.h
index 2b57fdc..7749140 100644
--- a/include/vlc_arrays.h
+++ b/include/vlc_arrays.h
@@ -103,15 +103,13 @@ static inline void *realloc_down( void *ptr, size_t size )
 #define TAB_APPEND( count, tab, p )             \
     TAB_APPEND_CAST( , count, tab, p )
 
-#define TAB_FIND( count, tab, p, index )        \
+#define TAB_FIND( count, tab, p, idx )          \
   do {                                          \
-    (index) = -1;                               \
-    for( int i = 0; i < (count); i++ )          \
-        if( (tab)[i] == (p) )                   \
-        {                                       \
-            (index) = i;                        \
+    for( (idx) = 0; (idx) < (count); (idx)++ )  \
+        if( (tab)[(idx)] == (p) )               \
             break;                              \
-        }                                       \
+    if( (idx) >= (count) )                      \
+        (idx) = -1;                             \
   } while(0)
 
 

_______________________________________________
vlc-commits mailing list
[email protected]
http://mailman.videolan.org/listinfo/vlc-commits

Reply via email to