[vlc-devel] commit: No need to test for NULL before free and use calloc when applicable . ( Rémi Duraffort )
git version control
git at videolan.org
Fri Jun 26 10:25:00 CEST 2009
vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Fri Jun 26 10:24:03 2009 +0200| [f37f5180688e12cf9d5c6e7fb3af3e9e68bc02bd] | committer: Rémi Duraffort
No need to test for NULL before free and use calloc when applicable.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f37f5180688e12cf9d5c6e7fb3af3e9e68bc02bd
---
.../dynamicoverlay/dynamicoverlay_buffer.c | 5 +----
.../dynamicoverlay/dynamicoverlay_commands.c | 6 ++----
.../dynamicoverlay/dynamicoverlay_list.c | 4 +---
3 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/modules/video_filter/dynamicoverlay/dynamicoverlay_buffer.c b/modules/video_filter/dynamicoverlay/dynamicoverlay_buffer.c
index b454ebf..3893bc0 100644
--- a/modules/video_filter/dynamicoverlay/dynamicoverlay_buffer.c
+++ b/modules/video_filter/dynamicoverlay/dynamicoverlay_buffer.c
@@ -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;
diff --git a/modules/video_filter/dynamicoverlay/dynamicoverlay_commands.c b/modules/video_filter/dynamicoverlay/dynamicoverlay_commands.c
index cf7ce62..f1c4213 100644
--- a/modules/video_filter/dynamicoverlay/dynamicoverlay_commands.c
+++ b/modules/video_filter/dynamicoverlay/dynamicoverlay_commands.c
@@ -48,10 +48,9 @@
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;
diff --git a/modules/video_filter/dynamicoverlay/dynamicoverlay_list.c b/modules/video_filter/dynamicoverlay/dynamicoverlay_list.c
index 985d3c4..477815a 100644
--- a/modules/video_filter/dynamicoverlay/dynamicoverlay_list.c
+++ b/modules/video_filter/dynamicoverlay/dynamicoverlay_list.c
@@ -38,13 +38,11 @@
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;
}
More information about the vlc-devel
mailing list