[vlc-devel] commit: Added small block_ChainProperties helper. (Laurent Aimar )

git version control git at videolan.org
Wed Aug 27 00:21:03 CEST 2008


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Tue Aug 26 21:34:00 2008 +0200| [919002be3c4e9bc75d6c9a869f43d4db5904d8f5] | committer: Laurent Aimar 

Added small block_ChainProperties helper.

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

 include/vlc_block.h |   31 +++++++++++++++++++++++++------
 1 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/include/vlc_block.h b/include/vlc_block.h
index a17530e..ad1f22c 100644
--- a/include/vlc_block.h
+++ b/include/vlc_block.h
@@ -217,20 +217,39 @@ static size_t block_ChainExtract( block_t *p_list, void *p_data, size_t i_max )
     return i_total;
 }
 
+static inline void block_ChainProperties( block_t *p_list, int *pi_count, size_t *pi_size, mtime_t *pi_length )
+{
+    size_t i_size = 0;
+    mtime_t i_length = 0;
+    int i_count;
+
+    while( p_list )
+    {
+        i_size += p_list->i_buffer;
+        i_length += p_list->i_length;
+        i_count++;
+
+        p_list = p_list->p_next;
+    }
+
+    if( pi_size )
+        *pi_size = i_size;
+    if( pi_length )
+        *pi_length = i_length;
+    if( pi_count )
+        *pi_count = i_count;
+}
+
 static inline block_t *block_ChainGather( block_t *p_list )
 {
     size_t  i_total = 0;
     mtime_t i_length = 0;
-    block_t *b, *g;
+    block_t *g;
 
     if( p_list->p_next == NULL )
         return p_list;  /* Already gathered */
 
-    for( b = p_list; b != NULL; b = b->p_next )
-    {
-        i_total += b->i_buffer;
-        i_length += b->i_length;
-    }
+    block_ChainProperties( p_list, NULL, &i_total, &i_length );
 
     g = block_Alloc( i_total );
     block_ChainExtract( p_list, g->p_buffer, g->i_buffer );




More information about the vlc-devel mailing list