Commit f37f5180 authored by ivoire's avatar ivoire
Browse files

No need to test for NULL before free and use calloc when applicable.

parent 00b2cd8d
...@@ -49,10 +49,7 @@ int BufferInit( buffer_t *p_buffer ) ...@@ -49,10 +49,7 @@ int BufferInit( buffer_t *p_buffer )
int BufferDestroy( buffer_t *p_buffer ) int BufferDestroy( buffer_t *p_buffer )
{ {
if( p_buffer->p_memory != NULL ) free( p_buffer->p_memory );
{
free( p_buffer->p_memory );
}
p_buffer->p_memory = NULL; p_buffer->p_memory = NULL;
p_buffer->p_begin = NULL; p_buffer->p_begin = NULL;
......
...@@ -48,10 +48,9 @@ ...@@ -48,10 +48,9 @@
overlay_t *OverlayCreate( void ) overlay_t *OverlayCreate( void )
{ {
overlay_t *p_ovl = malloc( sizeof( overlay_t ) ); overlay_t *p_ovl = calloc( 1, sizeof( overlay_t ) );
if( p_ovl == NULL ) if( p_ovl == NULL )
return NULL; return NULL;
memset( p_ovl, 0, sizeof( overlay_t ) );
p_ovl->i_x = p_ovl->i_y = 0; p_ovl->i_x = p_ovl->i_y = 0;
p_ovl->i_alpha = 0xFF; p_ovl->i_alpha = 0xFF;
...@@ -66,8 +65,7 @@ overlay_t *OverlayCreate( void ) ...@@ -66,8 +65,7 @@ overlay_t *OverlayCreate( void )
int OverlayDestroy( overlay_t *p_ovl ) int OverlayDestroy( overlay_t *p_ovl )
{ {
if( p_ovl->data.p_text != NULL ) free( p_ovl->data.p_text );
free( p_ovl->data.p_text );
text_style_Delete( p_ovl->p_fontstyle ); text_style_Delete( p_ovl->p_fontstyle );
return VLC_SUCCESS; return VLC_SUCCESS;
......
...@@ -38,13 +38,11 @@ ...@@ -38,13 +38,11 @@
int ListInit( list_t *p_list ) int ListInit( list_t *p_list )
{ {
p_list->pp_head = malloc( 16 * sizeof( overlay_t * ) ); p_list->pp_head = calloc( 16, sizeof( overlay_t * ) );
if( p_list->pp_head == NULL ) if( p_list->pp_head == NULL )
return VLC_ENOMEM; return VLC_ENOMEM;
p_list->pp_tail = p_list->pp_head + 16; p_list->pp_tail = p_list->pp_head + 16;
memset( p_list->pp_head, 0, 16 * sizeof( overlay_t * ) );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
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