[vlc-commits] core: use vlc_alloc helper
Thomas Guillem
git at videolan.org
Sat Nov 11 17:21:58 CET 2017
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Sat Nov 11 17:18:08 2017 +0100| [4139b2721550f69acc80b5fb2e254705bb21908f] | committer: Thomas Guillem
core: use vlc_alloc helper
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4139b2721550f69acc80b5fb2e254705bb21908f
---
src/audio_output/output.c | 4 ++--
src/config/cmdline.c | 4 ++--
src/config/core.c | 6 +++---
src/input/control.c | 4 ++--
src/input/es_out_timeshift.c | 4 ++--
src/input/item.c | 2 +-
src/input/resource.c | 2 +-
src/input/services_discovery.c | 6 +++---
src/input/vlmshell.c | 2 +-
src/misc/interrupt.c | 2 +-
src/misc/objects.c | 2 +-
src/misc/renderer_discovery.c | 4 ++--
src/modules/bank.c | 2 +-
src/text/url.c | 2 +-
14 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/src/audio_output/output.c b/src/audio_output/output.c
index 3c72a50184..4fb7ab8d7f 100644
--- a/src/audio_output/output.c
+++ b/src/audio_output/output.c
@@ -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;
diff --git a/src/config/cmdline.c b/src/config/cmdline.c
index 882f22479b..535306cc1c 100644
--- a/src/config/cmdline.c
+++ b/src/config/cmdline.c
@@ -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 );
diff --git a/src/config/core.c b/src/config/core.c
index 1343966af0..fe6abb6e98 100644
--- a/src/config/core.c
+++ b/src/config/core.c
@@ -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;
diff --git a/src/input/control.c b/src/input/control.c
index 8d9ffc0b8a..bbed58f222 100644
--- a/src/input/control.c
+++ b/src/input/control.c
@@ -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] );
diff --git a/src/input/es_out_timeshift.c b/src/input/es_out_timeshift.c
index 48f42f5f45..722932c28d 100644
--- a/src/input/es_out_timeshift.c
+++ b/src/input/es_out_timeshift.c
@@ -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 )
diff --git a/src/input/item.c b/src/input/item.c
index 11cfccf8f7..5980543072 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -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) )
{
diff --git a/src/input/resource.c b/src/input/resource.c
index 2a57ac075f..ac808f6e8a 100644
--- a/src/input/resource.c
+++ b/src/input/resource.c
@@ -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;
diff --git a/src/input/services_discovery.c b/src/input/services_discovery.c
index c2028f885a..12a029ef6e 100644
--- a/src/input/services_discovery.c
+++ b/src/input/services_discovery.c
@@ -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))
{
diff --git a/src/input/vlmshell.c b/src/input/vlmshell.c
index 6c12b3ec2f..4f812b2d47 100644
--- a/src/input/vlmshell.c
+++ b/src/input/vlmshell.c
@@ -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;
diff --git a/src/misc/interrupt.c b/src/misc/interrupt.c
index 3fafaa4183..7004ed2c3a 100644
--- a/src/misc/interrupt.c
+++ b/src/misc/interrupt.c
@@ -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 */
diff --git a/src/misc/objects.c b/src/misc/objects.c
index c8fcccc9af..ea8620a4e5 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -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);
diff --git a/src/misc/renderer_discovery.c b/src/misc/renderer_discovery.c
index 21de88824a..6162c879aa 100644
--- a/src/misc/renderer_discovery.c
+++ b/src/misc/renderer_discovery.c
@@ -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))
{
diff --git a/src/modules/bank.c b/src/modules/bank.c
index 4cc0e9a74e..2e67a0d07e 100644
--- a/src/modules/bank.c
+++ b/src/modules/bank.c
@@ -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;
diff --git a/src/text/url.c b/src/text/url.c
index 1b602b599e..8ae24b7887 100644
--- a/src/text/url.c
+++ b/src/text/url.c
@@ -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))
More information about the vlc-commits
mailing list