]> git.sesse.net Git - vlc/blobdiff - include/vlc_arrays.h
l10n: Bengali update
[vlc] / include / vlc_arrays.h
index 2b57fdc3d1044e1c538d3f9b5a716413a038ae83..91f540533b3144f00d1e74bd47dc34cf69598276 100644 (file)
@@ -92,9 +92,9 @@ static inline void *realloc_down( void *ptr, size_t size )
 #define TAB_APPEND_CAST( cast, count, tab, p )             \
   do {                                          \
     if( (count) > 0 )                           \
-        (tab) = cast realloc( tab, sizeof( void ** ) * ( (count) + 1 ) ); \
+        (tab) = cast realloc( tab, sizeof( *(tab) ) * ( (count) + 1 ) ); \
     else                                        \
-        (tab) = cast malloc( sizeof( void ** ) );    \
+        (tab) = cast malloc( sizeof( *(tab) ) );    \
     if( !(tab) ) abort();                       \
     (tab)[count] = (p);                         \
     (count)++;                                  \
@@ -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)
 
 
@@ -125,7 +123,7 @@ static inline void *realloc_down( void *ptr, size_t size )
             {                                   \
                 memmove( ((void**)(tab) + i_index),    \
                          ((void**)(tab) + i_index+1),  \
-                         ( (count) - i_index - 1 ) * sizeof( void* ) );\
+                         ( (count) - i_index - 1 ) * sizeof( *(tab) ) );\
             }                                   \
             (count)--;                          \
             if( (count) == 0 )                  \
@@ -138,9 +136,9 @@ static inline void *realloc_down( void *ptr, size_t size )
 
 #define TAB_INSERT_CAST( cast, count, tab, p, index ) do { \
     if( (count) > 0 )                           \
-        (tab) = cast realloc( tab, sizeof( void ** ) * ( (count) + 1 ) ); \
+        (tab) = cast realloc( tab, sizeof( *(tab) ) * ( (count) + 1 ) ); \
     else                                        \
-        (tab) = cast malloc( sizeof( void ** ) );       \
+        (tab) = cast malloc( sizeof( *(tab) ) );       \
     if( !(tab) ) abort();                       \
     if( (count) - (index) > 0 )                 \
         memmove( (void**)(tab) + (index) + 1,   \