]> git.sesse.net Git - vlc/commitdiff
No need to test for NULL before free and use calloc when applicable.
authorRémi Duraffort <ivoire@videolan.org>
Fri, 26 Jun 2009 08:24:03 +0000 (10:24 +0200)
committerRémi Duraffort <ivoire@videolan.org>
Fri, 26 Jun 2009 08:24:03 +0000 (10:24 +0200)
modules/video_filter/dynamicoverlay/dynamicoverlay_buffer.c
modules/video_filter/dynamicoverlay/dynamicoverlay_commands.c
modules/video_filter/dynamicoverlay/dynamicoverlay_list.c

index b454ebf5b8db04c9279b534fd61f04616c882f9a..3893bc067aab66b88a6166c8cbec82e47a193a5b 100644 (file)
@@ -49,10 +49,7 @@ int BufferInit( 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_begin = NULL;
 
index cf7ce627d1baa9d0cd8c0fa2529bd67aed0efcde..f1c4213022b756ec4deecfde2375c35782c2685a 100644 (file)
 
 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 )
        return NULL;
-    memset( p_ovl, 0, sizeof( overlay_t ) );
 
     p_ovl->i_x = p_ovl->i_y = 0;
     p_ovl->i_alpha = 0xFF;
@@ -66,8 +65,7 @@ overlay_t *OverlayCreate( void )
 
 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 );
 
     return VLC_SUCCESS;
index 985d3c415fedf04141b9333574e976c069d12b05..477815a6dfda7e603f3eb9cca9db360552ea3c39 100644 (file)
 
 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 )
         return VLC_ENOMEM;
 
     p_list->pp_tail = p_list->pp_head + 16;
-    memset( p_list->pp_head, 0, 16 * sizeof( overlay_t * ) );
-
     return VLC_SUCCESS;
 }