[vlc-devel] commit: Use calloc instead of malloc+memset. ( Rémi Duraffort )

git version control git at videolan.org
Fri Dec 12 20:23:23 CET 2008


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Fri Dec 12 20:22:18 2008 +0100| [f65454be2a667c4f24bfdd3c35b7994d8eda0997] | committer: Rémi Duraffort 

Use calloc instead of malloc+memset.

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

 src/input/vlm.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/input/vlm.c b/src/input/vlm.c
index 7e1721f..e9d53ad 100644
--- a/src/input/vlm.c
+++ b/src/input/vlm.c
@@ -622,10 +622,9 @@ static int vlm_ControlMediaAdd( vlm_t *p_vlm, vlm_media_t *p_cfg, int64_t *p_id
         p_vlm->p_vod->pf_media_control = vlm_MediaVodControl;
     }
 
-    p_media = malloc( sizeof( vlm_media_sys_t ) );
+    p_media = calloc( 1, sizeof( vlm_media_sys_t ) );
     if( !p_media )
         return VLC_ENOMEM;
-    memset( p_media, 0, sizeof(vlm_media_sys_t) );
 
     if( p_cfg->b_vod )
         p_vlm->i_vod++;
@@ -743,12 +742,10 @@ static vlm_media_instance_sys_t *vlm_ControlMediaInstanceGetByName( vlm_media_sy
 }
 static vlm_media_instance_sys_t *vlm_MediaInstanceNew( vlm_t *p_vlm, const char *psz_name )
 {
-    vlm_media_instance_sys_t *p_instance = malloc( sizeof(vlm_media_instance_sys_t) );
+    vlm_media_instance_sys_t *p_instance = calloc( 1, sizeof(vlm_media_instance_sys_t) );
     if( !p_instance )
         return NULL;
 
-    memset( p_instance, 0, sizeof(vlm_media_instance_sys_t) );
-
     p_instance->psz_name = NULL;
     if( psz_name )
         p_instance->psz_name = strdup( psz_name );
@@ -1154,3 +1151,4 @@ int vlm_Control( vlm_t *p_vlm, int i_query, ... )
 
     return i_result;
 }
+




More information about the vlc-devel mailing list