Commit 7c2d9c9b authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

block_Realloc: shortcut the release case

parent 84207844
...@@ -106,7 +106,13 @@ block_t *block_Alloc( size_t i_size ) ...@@ -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_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; 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 ) 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 ) ...@@ -120,14 +126,6 @@ block_t *block_Realloc( block_t *p_block, ssize_t i_prebody, size_t i_body )
p_block = p_dup; 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 */ /* Adjust reserved header if there is enough room */
if( p_block->p_buffer - i_prebody > p_sys->p_allocated_buffer && if( p_block->p_buffer - i_prebody > p_sys->p_allocated_buffer &&
p_block->p_buffer - i_prebody < p_sys->p_allocated_buffer + p_block->p_buffer - i_prebody < p_sys->p_allocated_buffer +
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment