Commit 4139b272 authored by Thomas Guillem's avatar Thomas Guillem

core: use vlc_alloc helper

parent f5e485d1
......@@ -847,8 +847,8 @@ int aout_DevicesList (audio_output_t *aout, char ***ids, char ***names)
unsigned i = 0;
vlc_mutex_lock (&owner->dev.lock);
tabid = malloc (sizeof (*tabid) * owner->dev.count);
tabname = malloc (sizeof (*tabname) * owner->dev.count);
tabid = vlc_alloc (owner->dev.count, sizeof (*tabid));
tabname = vlc_alloc (owner->dev.count, sizeof (*tabname));
if (unlikely(tabid == NULL || tabname == NULL))
goto error;
......
......@@ -78,7 +78,7 @@ int config_LoadCmdLine( vlc_object_t *p_this, int i_argc,
* dealing with boolean to allow for --foo and --no-foo */
i_opts += p->conf.count + 2 * p->conf.booleans;
p_longopts = malloc( sizeof(*p_longopts) * (i_opts + 1) );
p_longopts = vlc_alloc( i_opts + 1, sizeof(*p_longopts) );
if( p_longopts == NULL )
return -1;
......@@ -94,7 +94,7 @@ int config_LoadCmdLine( vlc_object_t *p_this, int i_argc,
* us, ignoring the arity of the options */
if( b_ignore_errors )
{
argv_copy = (const char**)malloc( i_argc * sizeof(char *) );
argv_copy = vlc_alloc( i_argc, sizeof(char *) );
if( argv_copy == NULL )
{
free( psz_shortopts );
......
......@@ -318,8 +318,8 @@ ssize_t config_GetIntChoices (vlc_object_t *obj, const char *name,
return cfg->list.i_cb(obj, name, values, texts);
}
int64_t *vals = malloc (sizeof (*vals) * count);
char **txts = malloc (sizeof (*txts) * count);
int64_t *vals = vlc_alloc (count, sizeof (*vals));
char **txts = vlc_alloc (count, sizeof (*txts));
if (vals == NULL || txts == NULL)
{
errno = ENOMEM;
......@@ -480,7 +480,7 @@ int config_SortConfig (void)
for (p = vlc_plugins; p != NULL; p = p->next)
nconf += p->conf.size;
module_config_t **clist = malloc (sizeof (*clist) * nconf);
module_config_t **clist = vlc_alloc (nconf, sizeof (*clist));
if (unlikely(clist == NULL))
return VLC_ENOMEM;
......
......@@ -269,7 +269,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
int i;
*pi_bkmk = priv->i_bookmark;
*ppp_bkmk = malloc( sizeof(seekpoint_t *) * priv->i_bookmark );
*ppp_bkmk = vlc_alloc( priv->i_bookmark, sizeof(seekpoint_t *) );
for( i = 0; i < priv->i_bookmark; i++ )
{
(*ppp_bkmk)[i] =
......@@ -464,7 +464,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
return VLC_EGENERIC;
}
*pi_attachment = priv->i_attachment;
*ppp_attachment = malloc( sizeof(input_attachment_t*) * priv->i_attachment );
*ppp_attachment = vlc_alloc( priv->i_attachment, sizeof(input_attachment_t*));
for( int i = 0; i < priv->i_attachment; i++ )
(*ppp_attachment)[i] = vlc_input_attachment_Duplicate( priv->attachment[i] );
......
......@@ -351,7 +351,7 @@ es_out_t *input_EsOutTimeshiftNew( input_thread_t *p_input, es_out_t *p_next_out
const DWORD count = GetTempPath( 0, NULL );
if( count > 0 )
{
TCHAR *path = malloc( (count + 1) * sizeof(TCHAR) );
TCHAR *path = vlc_alloc( count + 1, sizeof(TCHAR) );
if( path != NULL )
{
DWORD ret = GetTempPath( count + 1, path );
......@@ -1146,7 +1146,7 @@ static ts_storage_t *TsStorageNew( const char *psz_tmp_path, int64_t i_tmp_size_
p_storage->i_cmd_w = 0;
p_storage->i_cmd_r = 0;
p_storage->i_cmd_max = 30000;
p_storage->p_cmd = malloc( p_storage->i_cmd_max * sizeof(*p_storage->p_cmd) );
p_storage->p_cmd = vlc_alloc( p_storage->i_cmd_max, sizeof(*p_storage->p_cmd) );
//fprintf( stderr, "\nSTORAGE name=%s size=%d KiB\n", p_storage->psz_file, p_storage->i_cmd_max * sizeof(*p_storage->p_cmd) /1024 );
if( !p_storage->p_cmd )
......
......@@ -171,7 +171,7 @@ void input_item_CopyOptions( input_item_t *p_child,
{
optv = malloc( p_parent->i_options * sizeof (*optv) );
if( likely(optv) )
flagv = malloc( p_parent->i_options * sizeof (*flagv) );
flagv = vlc_alloc( p_parent->i_options, sizeof (*flagv) );
if( likely(flagv) )
{
......
......@@ -315,7 +315,7 @@ static void HoldVouts( input_resource_t *p_resource, vout_thread_t ***ppp_vout,
if( p_resource->i_vout <= 0 )
goto exit;
pp_vout = malloc( p_resource->i_vout * sizeof(*pp_vout) );
pp_vout = vlc_alloc( p_resource->i_vout, sizeof(*pp_vout) );
if( !pp_vout )
goto exit;
......
......@@ -69,9 +69,9 @@ char **vlc_sd_GetNames (vlc_object_t *obj, char ***pppsz_longnames, int **pp_cat
return NULL;
}
char **names = malloc (sizeof(char *) * (count + 1));
char **longnames = malloc (sizeof(char *) * (count + 1));
int *categories = malloc(sizeof(int) * (count + 1));
char **names = vlc_alloc (count + 1, sizeof(char *));
char **longnames = vlc_alloc (count + 1, sizeof(char *));
int *categories = vlc_alloc (count + 1, sizeof(int));
if (unlikely (names == NULL || longnames == NULL || categories == NULL))
{
......
......@@ -854,7 +854,7 @@ int ExecuteCommand( vlm_t *p_vlm, const char *psz_command,
size_t i_command_len = strlen( psz_command );
char *buf = malloc( i_command_len + 1 ), *psz_buf = buf;
size_t i_ppsz_command_len = (3 + (i_command_len + 1) / 2);
char **ppsz_command = malloc( i_ppsz_command_len * sizeof(char *) );
char **ppsz_command = vlc_alloc( i_ppsz_command_len, sizeof(char *) );
vlm_message_t *p_message = NULL;
int i_ret = 0;
......
......@@ -385,7 +385,7 @@ int vlc_poll_i11e(struct pollfd *fds, unsigned nfds, int timeout)
}
else
{ /* Slow path but poll() is slow with large nfds anyway. */
struct pollfd *ufd = malloc((nfds + 1) * sizeof (*ufd));
struct pollfd *ufd = vlc_alloc(nfds + 1, sizeof (*ufd));
if (unlikely(ufd == NULL))
return -1; /* ENOMEM */
......
......@@ -521,7 +521,7 @@ vlc_list_t *vlc_list_children( vlc_object_t *obj )
if (count > 0)
{
l->p_values = malloc (count * sizeof (vlc_value_t));
l->p_values = vlc_alloc (count, sizeof (vlc_value_t));
if (unlikely(l->p_values == NULL))
{
vlc_mutex_unlock (&vlc_internals(obj)->tree_lock);
......
......@@ -211,8 +211,8 @@ vlc_rd_get_names(vlc_object_t *p_obj, char ***pppsz_names,
return VLC_EGENERIC;
}
char **ppsz_names = malloc(sizeof(char *) * (i_count + 1));
char **ppsz_longnames = malloc(sizeof(char *) * (i_count + 1));
char **ppsz_names = vlc_alloc(i_count + 1, sizeof(char *));
char **ppsz_longnames = vlc_alloc(i_count + 1, sizeof(char *));
if (unlikely(ppsz_names == NULL || ppsz_longnames == NULL))
{
......
......@@ -741,7 +741,7 @@ ssize_t module_list_cap (module_t ***restrict list, const char *name)
const vlc_modcap_t *cap = *cp;
size_t n = cap->modc;
module_t **tab = malloc (sizeof (*tab) * n);
module_t **tab = vlc_alloc (n, sizeof (*tab));
*list = tab;
if (unlikely(tab == NULL))
return -1;
......
......@@ -900,7 +900,7 @@ static char *vlc_idna_to_ascii (const char *idn)
goto error;
}
wchar_t *buf = malloc (sizeof (*buf) * len);
wchar_t *buf = vlc_alloc (len, sizeof (*buf));
if (unlikely(buf == NULL))
goto error;
if (!IdnToAscii (IDN_ALLOW_UNASSIGNED, wide, -1, buf, len))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment