[vlc-commits] core: use vlc_alloc helpers

Thomas Guillem git at videolan.org
Sun Nov 12 14:25:48 CET 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Sun Nov 12 11:42:13 2017 +0100| [6a593dd451d90e106beca2078dfc93ce09d2e98c] | committer: RĂ©mi Denis-Courmont

core: use vlc_alloc helpers

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

 include/vlc_input.h            | 2 +-
 include/vlc_timestamp_helper.h | 2 +-
 lib/media.c                    | 2 +-
 lib/media_player.c             | 2 +-
 src/input/control.c            | 2 +-
 src/input/item.c               | 2 +-
 src/misc/actions.c             | 2 +-
 src/modules/modules.c          | 2 +-
 src/network/httpd.c            | 2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/include/vlc_input.h b/include/vlc_input.h
index 711571b2b4..d20585ba33 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -139,7 +139,7 @@ static inline input_title_t *vlc_input_title_Duplicate( const input_title_t *t )
     dup->i_length    = t->i_length;
     if( t->i_seekpoint > 0 )
     {
-        dup->seekpoint = (seekpoint_t**)malloc( t->i_seekpoint * sizeof(seekpoint_t*) );
+        dup->seekpoint = (seekpoint_t**)vlc_alloc( t->i_seekpoint, sizeof(seekpoint_t*) );
         if( likely(dup->seekpoint) )
         {
             for( int i = 0; i < t->i_seekpoint; i++ )
diff --git a/include/vlc_timestamp_helper.h b/include/vlc_timestamp_helper.h
index 5e08c3560e..90840fbcf7 100644
--- a/include/vlc_timestamp_helper.h
+++ b/include/vlc_timestamp_helper.h
@@ -47,7 +47,7 @@ static inline timestamp_fifo_t *timestamp_FifoNew(uint32_t capacity)
     timestamp_fifo_t *fifo = calloc(1, sizeof(*fifo));
     if (!fifo)
         return NULL;
-    fifo->buffer = malloc(capacity * sizeof(*fifo->buffer));
+    fifo->buffer = vlc_alloc(capacity, sizeof(*fifo->buffer));
     if (!fifo->buffer) {
         free(fifo);
         return NULL;
diff --git a/lib/media.c b/lib/media.c
index 8da5a130e2..af246c6c7e 100644
--- a/lib/media.c
+++ b/lib/media.c
@@ -904,7 +904,7 @@ libvlc_media_get_tracks_info( libvlc_media_t *p_md, libvlc_media_track_info_t **
     vlc_mutex_lock( &p_input_item->lock );
 
     const int i_es = p_input_item->i_es;
-    *pp_es = (i_es > 0) ? malloc( i_es * sizeof(libvlc_media_track_info_t) ) : NULL;
+    *pp_es = (i_es > 0) ? vlc_alloc( i_es, sizeof(libvlc_media_track_info_t) ) : NULL;
 
     if( !*pp_es ) /* no ES, or OOM */
     {
diff --git a/lib/media_player.c b/lib/media_player.c
index ef34125aa5..daef2faedd 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -1513,7 +1513,7 @@ int libvlc_media_player_get_full_title_descriptions( libvlc_media_player_t *p_mi
     if( ret != VLC_SUCCESS )
         return -1;
 
-    libvlc_title_description_t **titles = malloc( count * sizeof (*titles) );
+    libvlc_title_description_t **titles = vlc_alloc( count, sizeof (*titles) );
     if( count > 0 && unlikely(titles == NULL) )
         return -1;
 
diff --git a/src/input/control.c b/src/input/control.c
index bbed58f222..5793e8cfbd 100644
--- a/src/input/control.c
+++ b/src/input/control.c
@@ -344,7 +344,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
         {
             vlc_mutex_lock( &priv->p_item->lock );
             unsigned count = priv->i_title;
-            input_title_t **array = malloc( count * sizeof (*array) );
+            input_title_t **array = vlc_alloc( count, sizeof (*array) );
 
             if( count > 0 && unlikely(array == NULL) )
             {
diff --git a/src/input/item.c b/src/input/item.c
index 5980543072..95198d4e60 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -169,7 +169,7 @@ void input_item_CopyOptions( input_item_t *p_child,
 
     if( p_parent->i_options > 0 )
     {
-        optv = malloc( p_parent->i_options * sizeof (*optv) );
+        optv = vlc_alloc( p_parent->i_options, sizeof (*optv) );
         if( likely(optv) )
             flagv = vlc_alloc( p_parent->i_options, sizeof (*flagv) );
 
diff --git a/src/misc/actions.c b/src/misc/actions.c
index 74585f6c70..65178c1bf4 100644
--- a/src/misc/actions.c
+++ b/src/misc/actions.c
@@ -615,7 +615,7 @@ vlc_actions_get_keycodes(vlc_object_t *p_obj, const char *psz_key_name,
             ++i_nb_keycodes;
     }
     ++i_nb_keycodes;
-    *pp_keycodes = malloc( i_nb_keycodes * sizeof( **pp_keycodes ) );
+    *pp_keycodes = vlc_alloc( i_nb_keycodes, sizeof( **pp_keycodes ) );
     if( unlikely( !*pp_keycodes ) )
     {
         free( psz_keys );
diff --git a/src/modules/modules.c b/src/modules/modules.c
index ab6d29584e..3ad50fb391 100644
--- a/src/modules/modules.c
+++ b/src/modules/modules.c
@@ -438,7 +438,7 @@ module_config_t *module_config_get( const module_t *module, unsigned *restrict p
 
     unsigned i,j;
     size_t size = plugin->conf.size;
-    module_config_t *config = malloc( size * sizeof( *config ) );
+    module_config_t *config = vlc_alloc( size, sizeof( *config ) );
 
     assert( psize != NULL );
     *psize = 0;
diff --git a/src/network/httpd.c b/src/network/httpd.c
index 629e762c47..3e27406b5c 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -2081,7 +2081,7 @@ int httpd_StreamSetHTTPHeaders(httpd_stream_t * p_stream,
         return VLC_SUCCESS;
     }
 
-    p_stream->p_http_headers = malloc(sizeof(httpd_header) * i_headers);
+    p_stream->p_http_headers = vlc_alloc(i_headers, sizeof(httpd_header));
     if (!p_stream->p_http_headers) {
         vlc_mutex_unlock(&p_stream->lock);
         return VLC_ENOMEM;



More information about the vlc-commits mailing list