[vlc-devel] commit: Use calloc when needed. ( Rémi Duraffort )

git version control git at videolan.org
Fri Dec 12 22:17:06 CET 2008


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

Use calloc when needed.

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

 src/input/decoder_synchro.c      |    5 ++---
 src/input/es_out.c               |    3 +--
 src/misc/image.c                 |    5 +++--
 src/misc/stats.c                 |    4 +---
 src/modules/entry.c              |    5 ++---
 src/playlist/item.c              |    2 +-
 src/stream_output/announce.c     |    6 ++----
 src/video_output/vout_pictures.c |    4 +---
 8 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/src/input/decoder_synchro.c b/src/input/decoder_synchro.c
index 4ff8c7b..b88230e 100644
--- a/src/input/decoder_synchro.c
+++ b/src/input/decoder_synchro.c
@@ -161,10 +161,9 @@ struct decoder_synchro_t
  *****************************************************************************/
 decoder_synchro_t * decoder_SynchroInit( decoder_t *p_dec, int i_frame_rate )
 {
-    decoder_synchro_t * p_synchro = malloc( sizeof(*p_synchro) );
-    if ( p_synchro == NULL )
+    decoder_synchro_t * p_synchro = calloc( 1, sizeof(*p_synchro) );
+    if( !p_synchro )
         return NULL;
-    memset( p_synchro, 0, sizeof(*p_synchro) );
 
     p_synchro->p_dec = p_dec;
     p_synchro->b_no_skip = !config_GetInt( p_dec, "skip-frames" );
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 65d0f78..5cd2cbb 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -1213,10 +1213,9 @@ static void vlc_epg_Merge( vlc_epg_t *p_dst, const vlc_epg_t *p_src )
         }
         if( b_add )
         {
-            vlc_epg_event_t *p_copy = malloc( sizeof(vlc_epg_event_t) );
+            vlc_epg_event_t *p_copy = calloc( 1, sizeof(vlc_epg_event_t) );
             if( !p_copy )
                 break;
-            memset( p_copy, 0, sizeof(vlc_epg_event_t) );
             p_copy->i_start = p_evt->i_start;
             p_copy->i_duration = p_evt->i_duration;
             p_copy->psz_name = p_evt->psz_name ? strdup( p_evt->psz_name ) : NULL;
diff --git a/src/misc/image.c b/src/misc/image.c
index a28b119..dc9efc5 100644
--- a/src/misc/image.c
+++ b/src/misc/image.c
@@ -79,9 +79,10 @@ static vlc_fourcc_t Ext2Fourcc( const char * );
  */
 image_handler_t *__image_HandlerCreate( vlc_object_t *p_this )
 {
-    image_handler_t *p_image = malloc( sizeof(image_handler_t) );
+    image_handler_t *p_image = calloc( 1, sizeof(image_handler_t) );
+    if( !p_image )
+        return NULL;
 
-    memset( p_image, 0, sizeof(image_handler_t) );
     p_image->p_parent = p_this;
 
     p_image->pf_read = ImageRead;
diff --git a/src/misc/stats.c b/src/misc/stats.c
index d6302bd..b2e03ef 100644
--- a/src/misc/stats.c
+++ b/src/misc/stats.c
@@ -143,12 +143,10 @@ int __stats_Get( vlc_object_t *p_this, counter_t *p_counter, vlc_value_t *val )
 input_stats_t *stats_NewInputStats( input_thread_t *p_input )
 {
     (void)p_input;
-    input_stats_t *p_stats = malloc( sizeof(input_stats_t) );
-
+    input_stats_t *p_stats = calloc( 1, sizeof(input_stats_t) );
     if( !p_stats )
         return NULL;
 
-    memset( p_stats, 0, sizeof(*p_stats) );
     vlc_mutex_init( &p_stats->lock );
     stats_ReinitInputStats( p_stats );
 
diff --git a/src/modules/entry.c b/src/modules/entry.c
index 860efb7..ac96e49 100644
--- a/src/modules/entry.c
+++ b/src/modules/entry.c
@@ -98,11 +98,10 @@ module_t *vlc_submodule_create (module_t *module)
 {
     assert (module != NULL);
 
-    module_t *submodule = malloc (sizeof (*submodule));
-    if (submodule == NULL)
+    module_t *submodule = calloc( 1, sizeof(*submodule) );
+    if( !submodule )
         return NULL;
 
-    memset (submodule, 0, sizeof (*submodule));
     vlc_gc_init (submodule, vlc_submodule_destruct);
 
     submodule->next = module->submodule;
diff --git a/src/playlist/item.c b/src/playlist/item.c
index 3eeda3e..28ad321 100644
--- a/src/playlist/item.c
+++ b/src/playlist/item.c
@@ -700,7 +700,7 @@ static int TreeMove( playlist_t *p_playlist, playlist_item_t *p_item,
     REMOVE_ELEM( p_detach->pp_children, p_detach->i_children, j );
 
     /* If j < i_newpos, we are moving the element from the top to the
-     * down of the playlist. So when removing the element we change have
+     * down of the playlist. So when removing the element we have
      * to change the position as we loose one element
      */
     if( j < i_newpos )
diff --git a/src/stream_output/announce.c b/src/stream_output/announce.c
index 925ce1a..261b69d 100644
--- a/src/stream_output/announce.c
+++ b/src/stream_output/announce.c
@@ -65,12 +65,10 @@ sout_AnnounceRegisterSDP( vlc_object_t *obj, const char *psz_sdp,
     assert (p_method == &sap_method);
     (void) p_method;
 
-    session_descriptor_t *p_session = malloc (sizeof (*p_session));
-
-    if (!p_session)
+    session_descriptor_t *p_session = calloc( 1, sizeof (*p_session) );
+    if( !p_session )
         return NULL;
 
-    memset( p_session, 0, sizeof( *p_session ) );
     p_session->psz_sdp = strdup( psz_sdp );
 
     /* GRUIK. We should not convert back-and-forth from string to numbers */
diff --git a/src/video_output/vout_pictures.c b/src/video_output/vout_pictures.c
index ef89817..ae53033 100644
--- a/src/video_output/vout_pictures.c
+++ b/src/video_output/vout_pictures.c
@@ -1006,12 +1006,10 @@ static void PictureReleaseCallback( picture_t *p_picture )
  *****************************************************************************/
 picture_t *picture_New( vlc_fourcc_t i_chroma, int i_width, int i_height, int i_aspect )
 {
-    picture_t *p_picture = malloc( sizeof(*p_picture) );
-
+    picture_t *p_picture = calloc( 1, sizeof(*p_picture) );
     if( !p_picture )
         return NULL;
 
-    memset( p_picture, 0, sizeof(*p_picture) );
     if( __vout_AllocatePicture( NULL, p_picture,
                                 i_chroma, i_width, i_height, i_aspect ) )
     {




More information about the vlc-devel mailing list