[vlc-devel] commit: block_Realloc: shortcut the release case ( Rémi Denis-Courmont )

git version control git at videolan.org
Fri May 30 18:05:35 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rem at videolan.org> | Fri May 30 19:07:06 2008 +0300| [7c2d9c9b74261d773cbce34e0243f28c99157f34]

block_Realloc: shortcut the release case

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

 src/misc/block.c |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/misc/block.c b/src/misc/block.c
index 2bd84b0..a350db5 100644
--- a/src/misc/block.c
+++ b/src/misc/block.c
@@ -106,7 +106,13 @@ block_t *block_Alloc( size_t i_size )
 block_t *block_Realloc( block_t *p_block, ssize_t i_prebody, size_t i_body )
 {
     block_sys_t *p_sys = (block_sys_t *)p_block;
-    ssize_t i_buffer_size;
+    ssize_t i_buffer_size = i_prebody + i_body;
+
+    if( i_buffer_size <= 0 )
+    {
+        block_Release( p_block );
+        return NULL;
+    }
 
     if( p_block->pf_release != BlockRelease )
     {
@@ -120,14 +126,6 @@ block_t *block_Realloc( block_t *p_block, ssize_t i_prebody, size_t i_body )
         p_block = p_dup;
     }
 
-    i_buffer_size = i_prebody + i_body;
-
-    if( i_buffer_size <= 0 )
-    {
-        block_Release( p_block );
-        return NULL;
-    }
-
     /* Adjust reserved header if there is enough room */
     if( p_block->p_buffer - i_prebody > p_sys->p_allocated_buffer &&
         p_block->p_buffer - i_prebody < p_sys->p_allocated_buffer +




More information about the vlc-devel mailing list