mirror of https://code.videolan.org/videolan/vlc
core: use vlc_alloc helpers
This commit is contained in:
parent
051431cd65
commit
6a593dd451
|
@ -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++ )
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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) )
|
||||
{
|
||||
|
|
|
@ -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) );
|
||||
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue