[vlc-commits] access: allocate p_sys vlc_malloc/vlc_calloc
Rémi Denis-Courmont
git at videolan.org
Mon Jun 19 21:52:31 CEST 2017
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jun 17 22:31:20 2017 +0300| [740dd861a4b2e5780e48720af50935aa57a677b7] | committer: Rémi Denis-Courmont
access: allocate p_sys vlc_malloc/vlc_calloc
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=740dd861a4b2e5780e48720af50935aa57a677b7
---
modules/access/alsa.c | 6 +-----
modules/access/attachment.c | 4 +---
modules/access/avio.c | 28 ++++++++--------------------
modules/access/bluray.c | 3 +--
modules/access/cdda.c | 18 ++++--------------
modules/access/concat.c | 3 +--
modules/access/dc1394.c | 7 +------
modules/access/directory.c | 4 +---
modules/access/dv.c | 3 +--
modules/access/file.c | 3 +--
modules/access/ftp.c | 7 ++-----
modules/access/http.c | 6 +-----
modules/access/idummy.c | 14 ++------------
modules/access/imem-access.c | 10 +++-------
modules/access/imem.c | 3 +--
modules/access/jack.c | 9 +--------
modules/access/nfs.c | 5 ++---
modules/access/oss.c | 3 +--
modules/access/pulse.c | 7 ++-----
modules/access/rdp.c | 5 +----
modules/access/satip.c | 4 +---
modules/access/sdp.c | 13 ++-----------
modules/access/sftp.c | 3 +--
modules/access/shm.c | 21 ++++++---------------
modules/access/smb.c | 5 +----
modules/access/timecode.c | 14 ++------------
modules/access/udp.c | 7 ++-----
modules/access/vdr.c | 3 +--
modules/access/vnc.c | 15 +++------------
modules/access/wasapi.c | 4 +---
30 files changed, 56 insertions(+), 181 deletions(-)
diff --git a/modules/access/alsa.c b/modules/access/alsa.c
index c2716cffcc..a265f24127 100644
--- a/modules/access/alsa.c
+++ b/modules/access/alsa.c
@@ -341,8 +341,7 @@ static uint16_t channel_maps[] = {
static int Open (vlc_object_t *obj)
{
demux_t *demux = (demux_t *)obj;
- demux_sys_t *sys = malloc (sizeof (*sys));
-
+ demux_sys_t *sys = vlc_malloc(obj, sizeof (*sys));
if (unlikely(sys == NULL))
return VLC_ENOMEM;
@@ -361,7 +360,6 @@ static int Open (vlc_object_t *obj)
{
msg_Err (demux, "cannot open ALSA device \"%s\": %s", device,
snd_strerror (val));
- free (sys);
return VLC_EGENERIC;
}
sys->pcm = pcm;
@@ -510,7 +508,6 @@ static int Open (vlc_object_t *obj)
return VLC_SUCCESS;
error:
snd_pcm_close (pcm);
- free (sys);
return VLC_EGENERIC;
}
@@ -523,5 +520,4 @@ static void Close (vlc_object_t *obj)
vlc_join (sys->thread, NULL);
snd_pcm_close (sys->pcm);
- free (sys);
}
diff --git a/modules/access/attachment.c b/modules/access/attachment.c
index 0f4a8c8811..98bdc93de6 100644
--- a/modules/access/attachment.c
+++ b/modules/access/attachment.c
@@ -73,7 +73,7 @@ static int Open(vlc_object_t *object)
if (!input)
return VLC_EGENERIC;
- access_sys_t *sys = malloc(sizeof (*sys));
+ access_sys_t *sys = vlc_malloc(object, sizeof (*sys));
if (unlikely(sys == NULL))
return VLC_ENOMEM;
@@ -84,7 +84,6 @@ static int Open(vlc_object_t *object)
if (sys->attachment == NULL) {
msg_Err(access, "Failed to find the attachment '%s'",
access->psz_location);
- free(sys);
return VLC_EGENERIC;
}
@@ -106,7 +105,6 @@ static void Close(vlc_object_t *object)
access_sys_t *sys = access->p_sys;
vlc_input_attachment_Delete(sys->attachment);
- free(sys);
}
/* */
diff --git a/modules/access/avio.c b/modules/access/avio.c
index cc4c0debbf..771ee919f5 100644
--- a/modules/access/avio.c
+++ b/modules/access/avio.c
@@ -124,7 +124,7 @@ static int SetupAvioCb(vlc_object_t *access)
int OpenAvio(vlc_object_t *object)
{
access_t *access = (access_t*)object;
- access_sys_t *sys = malloc(sizeof(*sys));
+ access_sys_t *sys = vlc_malloc(object, sizeof(*sys));
if (!sys)
return VLC_ENOMEM;
sys->context = NULL;
@@ -140,10 +140,8 @@ int OpenAvio(vlc_object_t *object)
access->psz_location) < 0)
url = NULL;
- if (!url) {
- free(sys);
+ if (!url)
return VLC_ENOMEM;
- }
/* */
vlc_init_avformat(object);
@@ -172,7 +170,7 @@ int OpenAvio(vlc_object_t *object)
msg_Err(access, "Failed to open %s: %s", url,
vlc_strerror_c(AVUNERROR(ret)));
free(url);
- goto error;
+ return VLC_EGENERIC;
}
free(url);
@@ -181,7 +179,7 @@ int OpenAvio(vlc_object_t *object)
if (SetupAvioCb(VLC_OBJECT(access))) {
msg_Err(access, "Module already in use");
avio_close(sys->context);
- goto error;
+ return VLC_EGENERIC;
}
#endif
@@ -202,10 +200,6 @@ int OpenAvio(vlc_object_t *object)
access->p_sys = sys;
return VLC_SUCCESS;
-
-error:
- free(sys);
- return VLC_EGENERIC;
}
/* */
@@ -221,7 +215,7 @@ int OutOpenAvio(vlc_object_t *object)
config_ChainParse( access, "sout-avio-", ppsz_sout_options, access->p_cfg );
- sout_access_out_sys_t *sys = malloc(sizeof(*sys));
+ sout_access_out_sys_t *sys = vlc_malloc(object, sizeof(*sys));
if (!sys)
return VLC_ENOMEM;
sys->context = NULL;
@@ -230,7 +224,7 @@ int OutOpenAvio(vlc_object_t *object)
vlc_init_avformat(object);
if (!access->psz_path)
- goto error;
+ return VLC_EGENERIC;
int ret;
#if LIBAVFORMAT_VERSION_MAJOR < 54
@@ -252,14 +246,14 @@ int OutOpenAvio(vlc_object_t *object)
if (ret < 0) {
errno = AVUNERROR(ret);
msg_Err(access, "Failed to open %s", access->psz_path);
- goto error;
+ return VLC_EGENERIC;
}
#if LIBAVFORMAT_VERSION_MAJOR < 54
/* We can accept only one active user at any time */
if (SetupAvioCb(VLC_OBJECT(access))) {
msg_Err(access, "Module already in use");
- goto error;
+ return VLC_EGENERIC;
}
#endif
@@ -269,10 +263,6 @@ int OutOpenAvio(vlc_object_t *object)
access->p_sys = sys;
return VLC_SUCCESS;
-
-error:
- free(sys);
- return VLC_EGENERIC;
}
void CloseAvio(vlc_object_t *object)
@@ -285,7 +275,6 @@ void CloseAvio(vlc_object_t *object)
#endif
avio_close(sys->context);
- free(sys);
}
void OutCloseAvio(vlc_object_t *object)
@@ -298,7 +287,6 @@ void OutCloseAvio(vlc_object_t *object)
#endif
avio_close(sys->context);
- free(sys);
}
static ssize_t Read(access_t *access, void *data, size_t size)
diff --git a/modules/access/bluray.c b/modules/access/bluray.c
index dc5142fe9b..e6c0653eef 100644
--- a/modules/access/bluray.c
+++ b/modules/access/bluray.c
@@ -653,7 +653,7 @@ static int blurayOpen(vlc_object_t *object)
}
/* */
- p_demux->p_sys = p_sys = calloc(1, sizeof(*p_sys));
+ p_demux->p_sys = p_sys = vlc_calloc(obj, 1, sizeof(*p_sys));
if (unlikely(!p_sys))
return VLC_ENOMEM;
@@ -902,7 +902,6 @@ static void blurayClose(vlc_object_t *object)
vlc_mutex_destroy(&p_sys->read_block_lock);
free(p_sys->psz_bd_path);
- free(p_sys);
}
/*****************************************************************************
diff --git a/modules/access/cdda.c b/modules/access/cdda.c
index 4253991276..c32f2e4377 100644
--- a/modules/access/cdda.c
+++ b/modules/access/cdda.c
@@ -223,17 +223,11 @@ static int DemuxOpen(vlc_object_t *obj)
return VLC_EGENERIC;
if (track == 0 /* Whole disc -> use access plugin */)
- {
- ioctl_Close(obj, dev);
- return VLC_EGENERIC;
- }
+ goto error;
- demux_sys_t *sys = malloc(sizeof (*sys));
+ demux_sys_t *sys = vlc_malloc(obj, sizeof (*sys));
if (unlikely(sys == NULL))
- {
- ioctl_Close(obj, dev);
- return VLC_ENOMEM;
- }
+ goto error;
demux->p_sys = sys;
sys->vcddev = dev;
@@ -275,7 +269,6 @@ static int DemuxOpen(vlc_object_t *obj)
error:
ioctl_Close(obj, dev);
- free(sys);
return VLC_EGENERIC;
}
@@ -285,7 +278,6 @@ static void DemuxClose(vlc_object_t *obj)
demux_sys_t *sys = demux->p_sys;
ioctl_Close(obj, sys->vcddev);
- free(sys);
}
/*****************************************************************************
@@ -628,7 +620,7 @@ static int AccessOpen(vlc_object_t *obj)
return VLC_EGENERIC;
}
- access_sys_t *sys = malloc(sizeof (*sys));
+ access_sys_t *sys = vlc_malloc(obj, sizeof (*sys));
if (unlikely(sys == NULL))
{
ioctl_Close(obj, dev);
@@ -679,7 +671,6 @@ static int AccessOpen(vlc_object_t *obj)
error:
free(sys->p_sectors);
ioctl_Close(obj, dev);
- free(sys);
return VLC_EGENERIC;
}
@@ -703,7 +694,6 @@ static void AccessClose(vlc_object_t *obj)
free(sys->p_sectors);
ioctl_Close(obj, sys->vcddev);
- free(sys);
}
/*****************************************************************************
diff --git a/modules/access/concat.c b/modules/access/concat.c
index 506aba27fc..043a42df4e 100644
--- a/modules/access/concat.c
+++ b/modules/access/concat.c
@@ -188,7 +188,7 @@ static int Open(vlc_object_t *obj)
if (list == NULL)
return VLC_EGENERIC;
- access_sys_t *sys = malloc(sizeof (*sys));
+ access_sys_t *sys = vlc_malloc(obj, sizeof (*sys));
if (unlikely(sys == NULL))
{
free(list);
@@ -298,7 +298,6 @@ static void Close(vlc_object_t *obj)
}
var_Destroy(access, "concat-list");
- free(sys);
}
#define INPUT_LIST_TEXT N_("Inputs list")
diff --git a/modules/access/dc1394.c b/modules/access/dc1394.c
index 4d12cf3303..d089e69ab3 100644
--- a/modules/access/dc1394.c
+++ b/modules/access/dc1394.c
@@ -176,7 +176,7 @@ static int Open( vlc_object_t *p_this )
p_demux->info.i_title = 0;
p_demux->info.i_seekpoint = 0;
- p_demux->p_sys = p_sys = calloc( 1, sizeof( demux_sys_t ) );
+ p_demux->p_sys = p_sys = vlc_calloc( p_this, 1, sizeof( demux_sys_t ) );
if( !p_sys )
return VLC_ENOMEM;
@@ -201,7 +201,6 @@ static int Open( vlc_object_t *p_this )
msg_Err( p_demux, "Bad MRL, please check the option line "
"(MRL was: %s)",
p_demux->psz_location );
- free( p_sys );
return VLC_EGENERIC;
}
@@ -209,14 +208,12 @@ static int Open( vlc_object_t *p_this )
if( !p_sys->p_dccontext )
{
msg_Err( p_demux, "Failed to initialise libdc1394");
- free( p_sys );
return VLC_EGENERIC;
}
if( FindCamera( p_sys, p_demux ) != VLC_SUCCESS )
{
dc1394_free( p_sys->p_dccontext );
- free( p_sys );
return VLC_EGENERIC;
}
@@ -224,7 +221,6 @@ static int Open( vlc_object_t *p_this )
{
msg_Err( p_demux, "No camera found !!" );
dc1394_free( p_sys->p_dccontext );
- free( p_sys );
return VLC_EGENERIC;
}
@@ -390,7 +386,6 @@ static void Close( vlc_object_t *p_this )
dc1394_free(p_sys->p_dccontext);
free( p_sys->video_device );
- free( p_sys );
}
#if 0
diff --git a/modules/access/directory.c b/modules/access/directory.c
index 6d4e105890..0f2deb7e48 100644
--- a/modules/access/directory.c
+++ b/modules/access/directory.c
@@ -53,7 +53,7 @@ struct access_sys_t
*****************************************************************************/
int DirInit (access_t *access, DIR *dir)
{
- access_sys_t *sys = malloc(sizeof (*sys));
+ access_sys_t *sys = vlc_malloc(VLC_OBJECT(access), sizeof (*sys));
if (unlikely(sys == NULL))
goto error;
@@ -77,7 +77,6 @@ int DirInit (access_t *access, DIR *dir)
error:
closedir(dir);
- free(sys);
return VLC_ENOMEM;
}
@@ -108,7 +107,6 @@ void DirClose(vlc_object_t *obj)
free(sys->base_uri);
closedir(sys->dir);
- free(sys);
}
int DirRead (access_t *access, input_item_node_t *node)
diff --git a/modules/access/dv.c b/modules/access/dv.c
index d81d2b6659..7af5e058fd 100644
--- a/modules/access/dv.c
+++ b/modules/access/dv.c
@@ -128,7 +128,7 @@ static int Open( vlc_object_t *p_this )
/* Set up p_access */
ACCESS_SET_CALLBACKS( NULL, Block, Control, NULL );
- p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
+ p_access->p_sys = p_sys = vlc_malloc( p_this, sizeof( access_sys_t ) );
if( !p_sys )
return VLC_EGENERIC;
@@ -259,7 +259,6 @@ static void Close( vlc_object_t *p_this )
AVCClose( p_access );
vlc_mutex_destroy( &p_sys->lock );
- free( p_sys );
}
/*****************************************************************************
diff --git a/modules/access/file.c b/modules/access/file.c
index 20cbb9401e..3b041fe699 100644
--- a/modules/access/file.c
+++ b/modules/access/file.c
@@ -211,7 +211,7 @@ int FileOpen( vlc_object_t *p_this )
#endif
}
- access_sys_t *p_sys = malloc (sizeof (*p_sys));
+ access_sys_t *p_sys = vlc_malloc(p_this, sizeof (*p_sys));
if (unlikely(p_sys == NULL))
goto error;
p_access->pf_read = Read;
@@ -268,7 +268,6 @@ void FileClose (vlc_object_t * p_this)
access_sys_t *p_sys = p_access->p_sys;
vlc_close (p_sys->fd);
- free (p_sys);
}
diff --git a/modules/access/ftp.c b/modules/access/ftp.c
index 0906048702..89c02c36bf 100644
--- a/modules/access/ftp.c
+++ b/modules/access/ftp.c
@@ -669,7 +669,7 @@ static int InOpen( vlc_object_t *p_this )
bool b_directory;
/* Init p_access */
- p_sys = p_access->p_sys = (access_sys_t*)calloc( 1, sizeof( access_sys_t ) );
+ p_sys = p_access->p_sys = (access_sys_t*)vlc_calloc( p_this, 1, sizeof( access_sys_t ) );
if( !p_sys )
return VLC_ENOMEM;
p_sys->data = NULL;
@@ -746,7 +746,6 @@ error:
exit_error:
vlc_UrlClean( &p_sys->url );
vlc_tls_Delete( p_sys->p_creds );
- free( p_sys );
return VLC_EGENERIC;
}
@@ -756,7 +755,7 @@ static int OutOpen( vlc_object_t *p_this )
sout_access_out_t *p_access = (sout_access_out_t *)p_this;
access_sys_t *p_sys;
- p_sys = calloc( 1, sizeof( *p_sys ) );
+ p_sys = vlc_calloc( p_this, 1, sizeof( *p_sys ) );
if( !p_sys )
return VLC_ENOMEM;
@@ -795,7 +794,6 @@ static int OutOpen( vlc_object_t *p_this )
exit_error:
vlc_UrlClean( &p_sys->url );
vlc_tls_Delete( p_sys->p_creds );
- free( p_sys );
return VLC_EGENERIC;
}
#endif
@@ -822,7 +820,6 @@ static void Close( vlc_object_t *p_access, access_sys_t *p_sys )
/* free memory */
vlc_UrlClean( &p_sys->url );
vlc_tls_Delete( p_sys->p_creds );
- free( p_sys );
}
static void InClose( vlc_object_t *p_this )
diff --git a/modules/access/http.c b/modules/access/http.c
index 084b3584e8..4efe574343 100644
--- a/modules/access/http.c
+++ b/modules/access/http.c
@@ -157,7 +157,7 @@ static int Open( vlc_object_t *p_this )
int ret = VLC_EGENERIC;
vlc_credential credential;
- access_sys_t *p_sys = malloc( sizeof(*p_sys) );
+ access_sys_t *p_sys = vlc_malloc( p_this, sizeof(*p_sys) );
if( unlikely(p_sys == NULL) )
return VLC_ENOMEM;
@@ -185,7 +185,6 @@ static int Open( vlc_object_t *p_this )
{
msg_Err( p_access, "invalid URL" );
vlc_UrlClean( &p_sys->url );
- free( p_sys );
return VLC_EGENERIC;
}
if( p_sys->url.i_port <= 0 )
@@ -376,7 +375,6 @@ error:
Disconnect( p_access );
- free( p_sys );
return ret;
}
@@ -407,8 +405,6 @@ static void Close( vlc_object_t *p_this )
free( p_sys->psz_password );
Disconnect( p_access );
-
- free( p_sys );
}
/* Read data from the socket */
diff --git a/modules/access/idummy.c b/modules/access/idummy.c
index 1e7a0fee32..b12e4d30da 100644
--- a/modules/access/idummy.c
+++ b/modules/access/idummy.c
@@ -42,7 +42,7 @@ vlc_module_begin ()
set_shortname( N_("Dummy") )
set_description( N_("Dummy input") )
set_capability( "access_demux", 0 )
- set_callbacks( OpenDemux, CloseDemux )
+ set_callbacks( OpenDemux, NULL )
add_shortcut( "dummy", "vlc" )
vlc_module_end ()
@@ -185,7 +185,7 @@ nop:
if( length == 0 )
goto nop; /* avoid division by zero */
- demux_sys_t *p_sys = malloc( sizeof( *p_sys ) );
+ demux_sys_t *p_sys = vlc_malloc( p_this, sizeof( *p_sys ) );
if( p_sys == NULL )
return VLC_ENOMEM;
@@ -202,16 +202,6 @@ nop:
return VLC_EGENERIC;
}
-/*****************************************************************************
- * CloseDemux: initialize the target, ie. parse the command
- *****************************************************************************/
-static void CloseDemux( vlc_object_t *p_this )
-{
- demux_t *p_demux = (demux_t*)p_this;
-
- free( p_demux->p_sys );
-}
-
static int DemuxControl( demux_t *p_demux, int i_query, va_list args )
{
(void)p_demux; (void)i_query; (void)args;
diff --git a/modules/access/imem-access.c b/modules/access/imem-access.c
index d7a80bb105..eb73c2d7c1 100644
--- a/modules/access/imem-access.c
+++ b/modules/access/imem-access.c
@@ -112,7 +112,7 @@ static int Open(vlc_object_t *object)
{
access_t *access = (access_t *)object;
- access_sys_t *sys = malloc(sizeof (*sys));
+ access_sys_t *sys = vlc_malloc(object, sizeof (*sys));
if (unlikely(sys == NULL))
return VLC_ENOMEM;
@@ -130,11 +130,11 @@ static int Open(vlc_object_t *object)
if (open_cb == NULL)
open_cb = open_cb_default;
if (sys->read_cb == NULL)
- goto error;
+ return VLC_EGENERIC;
if (open_cb(opaque, &sys->opaque, &sys->size)) {
msg_Err(access, "open error");
- goto error;
+ return VLC_EGENERIC;
}
access->pf_read = Read;
@@ -144,9 +144,6 @@ static int Open(vlc_object_t *object)
access->p_sys = sys;
return VLC_SUCCESS;
-error:
- free(sys);
- return VLC_EGENERIC;
}
static void Close(vlc_object_t *object)
@@ -156,7 +153,6 @@ static void Close(vlc_object_t *object)
if (sys->close_cb != NULL)
sys->close_cb(sys->opaque);
- free(sys);
}
vlc_module_begin()
diff --git a/modules/access/imem.c b/modules/access/imem.c
index 9999c46cb6..60ff35287e 100644
--- a/modules/access/imem.c
+++ b/modules/access/imem.c
@@ -230,7 +230,6 @@ static void ParseMRL(vlc_object_t *, const char *);
static void CloseCommon(imem_sys_t *sys)
{
free(sys->source.cookie);
- free(sys);
}
/**
@@ -241,7 +240,7 @@ static int OpenCommon(vlc_object_t *object, imem_sys_t **sys_ptr, const char *ps
char *tmp;
/* */
- imem_sys_t *sys = calloc(1, sizeof(*sys));
+ imem_sys_t *sys = vlc_calloc(object, 1, sizeof(*sys));
if (!sys)
return VLC_ENOMEM;
diff --git a/modules/access/jack.c b/modules/access/jack.c
index a4fed98a59..fa48b51024 100644
--- a/modules/access/jack.c
+++ b/modules/access/jack.c
@@ -131,7 +131,7 @@ static int Open( vlc_object_t *p_this )
p_demux->pf_control = Control;
/* Allocate structure */
- p_demux->p_sys = p_sys = calloc( 1, sizeof( demux_sys_t ) );
+ p_demux->p_sys = p_sys = vlc_calloc( p_this, 1, sizeof( demux_sys_t ) );
if( !p_sys )
return VLC_ENOMEM;
@@ -152,7 +152,6 @@ static int Open( vlc_object_t *p_this )
if( p_sys->p_jack_client == NULL )
{
msg_Err( p_demux, "failed to connect to JACK server" );
- free( p_sys );
return VLC_EGENERIC;
}
@@ -173,7 +172,6 @@ static int Open( vlc_object_t *p_this )
if( p_sys->pp_jack_port_input == NULL )
{
jack_client_close( p_sys->p_jack_client );
- free( p_sys );
return VLC_ENOMEM;
}
@@ -187,7 +185,6 @@ static int Open( vlc_object_t *p_this )
{
free( p_sys->pp_jack_port_input );
jack_client_close( p_sys->p_jack_client );
- free( p_sys );
return VLC_ENOMEM;
}
@@ -205,7 +202,6 @@ static int Open( vlc_object_t *p_this )
jack_ringbuffer_free( p_sys->p_jack_ringbuffer );
free( p_sys->pp_jack_port_input );
jack_client_close( p_sys->p_jack_client );
- free( p_sys );
return VLC_EGENERIC;
}
}
@@ -220,7 +216,6 @@ static int Open( vlc_object_t *p_this )
jack_ringbuffer_free( p_sys->p_jack_ringbuffer );
free( p_sys->pp_jack_port_input );
jack_client_close( p_sys->p_jack_client );
- free( p_sys );
return VLC_ENOMEM;
}
@@ -237,7 +232,6 @@ static int Open( vlc_object_t *p_this )
jack_ringbuffer_free( p_sys->p_jack_ringbuffer );
free( p_sys->pp_jack_port_input );
jack_client_close( p_sys->p_jack_client );
- free( p_sys );
return VLC_EGENERIC;
}
@@ -314,7 +308,6 @@ static void Close( vlc_object_t *p_this )
free( p_sys->pp_jack_port_input );
free( p_sys->pp_jack_buffer );
free( p_sys->pp_jack_port_table );
- free( p_sys );
}
diff --git a/modules/access/nfs.c b/modules/access/nfs.c
index ce5d4d361b..e6414aa460 100644
--- a/modules/access/nfs.c
+++ b/modules/access/nfs.c
@@ -621,10 +621,10 @@ static int
Open(vlc_object_t *p_obj)
{
access_t *p_access = (access_t *)p_obj;
- access_sys_t *p_sys = calloc(1, sizeof (*p_sys));
+ access_sys_t *p_sys = vlc_calloc(p_obj, 1, sizeof (*p_sys));
if (unlikely(p_sys == NULL))
- goto error;
+ return VLC_ENOMEM;
p_access->p_sys = p_sys;
p_sys->b_auto_guid = var_InheritBool(p_obj, "nfs-auto-guid");
@@ -770,5 +770,4 @@ Close(vlc_object_t *p_obj)
free(p_sys->psz_url_decoded);
free(p_sys->psz_url_decoded_slash);
- free(p_sys);
}
diff --git a/modules/access/oss.c b/modules/access/oss.c
index caadb92e6b..802dbf010f 100644
--- a/modules/access/oss.c
+++ b/modules/access/oss.c
@@ -160,7 +160,7 @@ static int DemuxOpen( vlc_object_t *p_this )
p_demux->info.i_title = 0;
p_demux->info.i_seekpoint = 0;
- p_demux->p_sys = p_sys = calloc( 1, sizeof( demux_sys_t ) );
+ p_demux->p_sys = p_sys = vlc_calloc( p_this, 1, sizeof( demux_sys_t ) );
if( p_sys == NULL ) return VLC_ENOMEM;
p_sys->i_sample_rate = var_InheritInteger( p_demux, CFG_PREFIX "samplerate" );
@@ -196,7 +196,6 @@ static void DemuxClose( vlc_object_t *p_this )
vlc_close( p_sys->i_fd );
if( p_sys->p_block ) block_Release( p_sys->p_block );
- free( p_sys );
}
/*****************************************************************************
diff --git a/modules/access/pulse.c b/modules/access/pulse.c
index 1dc22f1805..9d1a1e82b6 100644
--- a/modules/access/pulse.c
+++ b/modules/access/pulse.c
@@ -255,15 +255,13 @@ static int Open(vlc_object_t *obj)
{
demux_t *demux = (demux_t *)obj;
- demux_sys_t *sys = malloc(sizeof (*sys));
+ demux_sys_t *sys = vlc_malloc(obj, sizeof (*sys));
if (unlikely(sys == NULL))
return VLC_ENOMEM;
sys->context = vlc_pa_connect(obj, &sys->mainloop);
- if (sys->context == NULL) {
- free(sys);
+ if (sys->context == NULL)
return VLC_EGENERIC;
- }
sys->stream = NULL;
sys->es = NULL;
@@ -396,5 +394,4 @@ static void Close (vlc_object_t *obj)
}
vlc_pa_disconnect(obj, sys->context, sys->mainloop);
- free(sys);
}
diff --git a/modules/access/rdp.c b/modules/access/rdp.c
index 21d2166a84..926994cbd7 100644
--- a/modules/access/rdp.c
+++ b/modules/access/rdp.c
@@ -425,7 +425,7 @@ static int Open( vlc_object_t *p_this )
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys;
- p_sys = calloc( 1, sizeof(demux_sys_t) );
+ p_sys = vlc_calloc( p_this, 1, sizeof(demux_sys_t) );
if( !p_sys ) return VLC_ENOMEM;
p_sys->f_fps = var_InheritFloat( p_demux, CFG_PREFIX "fps" );
@@ -440,7 +440,6 @@ static int Open( vlc_object_t *p_this )
if ( !p_sys->p_instance )
{
msg_Err( p_demux, "rdp instantiation error" );
- free( p_sys );
return VLC_EGENERIC;
}
@@ -490,7 +489,6 @@ static int Open( vlc_object_t *p_this )
error:
freerdp_free( p_sys->p_instance );
free( p_sys->psz_hostname );
- free( p_sys );
return VLC_EGENERIC;
}
@@ -518,5 +516,4 @@ static void Close( vlc_object_t *p_this )
block_Release( p_sys->p_block );
free( p_sys->psz_hostname );
- free( p_sys );
}
diff --git a/modules/access/satip.c b/modules/access/satip.c
index cfbc4677b4..04b47764cd 100644
--- a/modules/access/satip.c
+++ b/modules/access/satip.c
@@ -626,7 +626,7 @@ static int satip_open(vlc_object_t *obj)
bool multicast = var_InheritBool(access, "satip-multicast");
- access->p_sys = sys = calloc(1, sizeof(*sys));
+ access->p_sys = sys = vlc_calloc(obj, 1, sizeof(*sys));
if (sys == NULL)
return VLC_ENOMEM;
@@ -804,7 +804,6 @@ error:
free(sys->content_base);
free(sys->control);
- free(sys);
return VLC_EGENERIC;
}
@@ -824,5 +823,4 @@ static void satip_close(vlc_object_t *obj)
net_Close(sys->tcp_sock);
free(sys->content_base);
free(sys->control);
- free(sys);
}
diff --git a/modules/access/sdp.c b/modules/access/sdp.c
index 74cef0735c..f095a7d76a 100644
--- a/modules/access/sdp.c
+++ b/modules/access/sdp.c
@@ -27,7 +27,6 @@
#include <vlc_access.h>
static int Open (vlc_object_t *);
-static void Close (vlc_object_t *);
vlc_module_begin ()
set_shortname (N_("SDP"))
@@ -36,7 +35,7 @@ vlc_module_begin ()
set_subcategory (SUBCAT_INPUT_ACCESS)
set_capability ("access", 0)
- set_callbacks (Open, Close)
+ set_callbacks (Open, NULL)
add_shortcut ("sdp")
vlc_module_end()
@@ -56,7 +55,7 @@ static int Open (vlc_object_t *obj)
access_t *access = (access_t *)obj;
size_t len = strlen (access->psz_location);
- access_sys_t *sys = malloc (sizeof(*sys) + len);
+ access_sys_t *sys = vlc_malloc(obj, sizeof(*sys) + len);
if (unlikely(sys == NULL))
return VLC_ENOMEM;
@@ -74,14 +73,6 @@ static int Open (vlc_object_t *obj)
return VLC_SUCCESS;
}
-static void Close (vlc_object_t *obj)
-{
- access_t *access = (access_t *)obj;
- access_sys_t *sys = access->p_sys;
-
- free (sys);
-}
-
static ssize_t Read (access_t *access, void *buf, size_t len)
{
access_sys_t *sys = access->p_sys;
diff --git a/modules/access/sftp.c b/modules/access/sftp.c
index fc5e529787..f43975dfd8 100644
--- a/modules/access/sftp.c
+++ b/modules/access/sftp.c
@@ -197,7 +197,7 @@ static int Open( vlc_object_t* p_this )
if( !p_access->psz_location )
return VLC_EGENERIC;
- p_sys = p_access->p_sys = (access_sys_t*)calloc( 1, sizeof( access_sys_t ) );
+ p_sys = p_access->p_sys = vlc_calloc( p_this, 1, sizeof( access_sys_t ) );
if( !p_sys ) return VLC_ENOMEM;
p_sys->i_socket = -1;
@@ -452,7 +452,6 @@ static void Close( vlc_object_t* p_this )
net_Close( p_sys->i_socket );
free( p_sys->psz_base_url );
- free( p_sys );
}
diff --git a/modules/access/shm.c b/modules/access/shm.c
index 0d9369efe9..86ff704a67 100644
--- a/modules/access/shm.c
+++ b/modules/access/shm.c
@@ -117,7 +117,6 @@ static void CloseFile (demux_sys_t *);
static void DemuxIPC (void *);
static void CloseIPC (demux_sys_t *);
#endif
-static void no_detach (demux_sys_t *);
struct demux_sys_t
{
@@ -139,10 +138,9 @@ struct demux_sys_t
static int Open (vlc_object_t *obj)
{
demux_t *demux = (demux_t *)obj;
- demux_sys_t *sys = malloc (sizeof (*sys));
+ demux_sys_t *sys = vlc_malloc(obj, sizeof (*sys));
if (unlikely(sys == NULL))
return VLC_ENOMEM;
- sys->detach = no_detach;
uint32_t chroma;
uint16_t width = 0, height = 0;
@@ -168,7 +166,7 @@ static int Open (vlc_object_t *obj)
chroma = VLC_CODEC_XWD; bpp = 0;
break;
default:
- goto error;
+ return VLC_EGENERIC;
}
if (bpp != 0)
{
@@ -187,7 +185,7 @@ static int Open (vlc_object_t *obj)
vlc_strerror_c(errno));
free (path);
if (sys->fd == -1)
- goto error;
+ return VLC_EGENERIC;
sys->detach = CloseFile;
Demux = DemuxFile;
@@ -197,18 +195,18 @@ static int Open (vlc_object_t *obj)
#ifdef HAVE_SYS_SHM_H
sys->mem.length = width * height * (bpp >> 3);
if (sys->mem.length == 0)
- goto error;
+ return VLC_EGENERIC;
int id = var_InheritInteger (demux, "shm-id");
if (id == IPC_PRIVATE)
- goto error;
+ return VLC_EGENERIC;
void *mem = shmat (id, NULL, SHM_RDONLY);
if (mem == (const void *)(-1))
{
msg_Err (demux, "cannot attach segment %d: %s", id,
vlc_strerror_c(errno));
- goto error;
+ return VLC_EGENERIC;
}
sys->mem.addr = mem;
sys->detach = CloseIPC;
@@ -251,7 +249,6 @@ static int Open (vlc_object_t *obj)
error:
sys->detach (sys);
- free (sys);
return VLC_EGENERIC;
}
@@ -266,12 +263,6 @@ static void Close (vlc_object_t *obj)
vlc_timer_destroy (sys->timer);
sys->detach (sys);
- free (sys);
-}
-
-static void no_detach (demux_sys_t *sys)
-{
- (void) sys;
}
/**
diff --git a/modules/access/smb.c b/modules/access/smb.c
index 57e058926a..4075259f17 100644
--- a/modules/access/smb.c
+++ b/modules/access/smb.c
@@ -225,7 +225,7 @@ static int Open( vlc_object_t *p_this )
/* Init p_access */
p_sys =
- p_access->p_sys = (access_sys_t*)calloc( 1, sizeof( access_sys_t ) );
+ p_access->p_sys = vlc_calloc( p_this, 1, sizeof( access_sys_t ) );
if( !p_sys )
{
free( psz_uri );
@@ -236,7 +236,6 @@ static int Open( vlc_object_t *p_this )
if( b_is_dir )
{
#ifdef _WIN32
- free( p_sys );
free( psz_uri );
vlc_UrlClean( &url );
return VLC_EGENERIC;
@@ -263,7 +262,6 @@ static int Open( vlc_object_t *p_this )
{
msg_Err( p_access, "open failed for '%s' (%s)",
p_access->psz_location, vlc_strerror_c(errno) );
- free( p_sys );
return VLC_EGENERIC;
}
@@ -289,7 +287,6 @@ static void Close( vlc_object_t *p_this )
else
#endif
smbc_close( p_sys->i_smb );
- free( p_sys );
}
/*****************************************************************************
diff --git a/modules/access/timecode.c b/modules/access/timecode.c
index 8e37e2ca16..b7116239a8 100644
--- a/modules/access/timecode.c
+++ b/modules/access/timecode.c
@@ -34,7 +34,6 @@
#define FPS_TEXT N_("Frame rate")
static int Open (vlc_object_t *);
-static void Close (vlc_object_t *);
static const char *const fps_values[] = { "24/1", "25/1", "30000/1001", "30/1" };
static const char *const fps_texts[] = { "24", "25", "29.97", "30" };
@@ -45,7 +44,7 @@ vlc_module_begin ()
set_category (CAT_INPUT)
set_subcategory (SUBCAT_INPUT_ACCESS)
set_capability ("access_demux", 0)
- set_callbacks (Open, Close)
+ set_callbacks (Open, NULL)
add_string ("timecode-fps", "25/1", FPS_TEXT, FPS_TEXT, false)
change_string_list (fps_values, fps_texts)
@@ -168,7 +167,7 @@ static int Control (demux_t *demux, int query, va_list args)
static int Open (vlc_object_t *obj)
{
demux_t *demux = (demux_t *)obj;
- demux_sys_t *sys = malloc (sizeof (*sys));
+ demux_sys_t *sys = vlc_malloc(obj, sizeof (*sys));
if (unlikely(sys == NULL))
return VLC_ENOMEM;
@@ -182,7 +181,6 @@ static int Open (vlc_object_t *obj)
|| !num || !den)
{
msg_Err (demux, "invalid frame rate");
- free (sys);
return VLC_EGENERIC;
}
@@ -195,11 +193,3 @@ static int Open (vlc_object_t *obj)
demux->pf_control = Control;
return VLC_SUCCESS;
}
-
-static void Close (vlc_object_t *obj)
-{
- demux_t *demux = (demux_t *)obj;
- demux_sys_t *sys = demux->p_sys;
-
- free (sys);
-}
diff --git a/modules/access/udp.c b/modules/access/udp.c
index 9e242f8c70..c3bcf6c5db 100644
--- a/modules/access/udp.c
+++ b/modules/access/udp.c
@@ -100,7 +100,7 @@ static int Open( vlc_object_t *p_this )
if( p_access->b_preparsing )
return VLC_EGENERIC;
- sys = malloc( sizeof( *sys ) );
+ sys = vlc_malloc( p_this, sizeof( *sys ) );
if( unlikely( sys == NULL ) )
return VLC_ENOMEM;
@@ -115,7 +115,7 @@ static int Open( vlc_object_t *p_this )
int i_bind_port = 1234, i_server_port = 0;
if( unlikely(psz_name == NULL) )
- goto error;
+ return VLC_ENOMEM;
/* Parse psz_name syntax :
* [serveraddr[:serverport]][@[bindaddr]:[bindport]] */
@@ -165,8 +165,6 @@ static int Open( vlc_object_t *p_this )
if( sys->fd == -1 )
{
msg_Err( p_access, "cannot open socket" );
-error:
- free( sys );
return VLC_EGENERIC;
}
@@ -188,7 +186,6 @@ static void Close( vlc_object_t *p_this )
access_sys_t *sys = p_access->p_sys;
net_Close( sys->fd );
- free( sys );
}
/*****************************************************************************
diff --git a/modules/access/vdr.c b/modules/access/vdr.c
index 81b549cb75..22528c6cbf 100644
--- a/modules/access/vdr.c
+++ b/modules/access/vdr.c
@@ -188,7 +188,7 @@ static int Open( vlc_object_t *p_this )
!S_ISDIR( st.st_mode ) )
return VLC_EGENERIC;
- access_sys_t *p_sys = calloc( 1, sizeof( *p_sys ) );
+ access_sys_t *p_sys = vlc_calloc( p_this, 1, sizeof( *p_sys ) );
if( unlikely(p_sys == NULL) )
return VLC_ENOMEM;
@@ -229,7 +229,6 @@ static void Close( vlc_object_t * p_this )
size_t count = p_sys->p_marks->i_seekpoint;
TAB_CLEAN( count, p_sys->offsets );
vlc_input_title_Delete( p_sys->p_marks );
- free( p_sys );
}
/*****************************************************************************
diff --git a/modules/access/vnc.c b/modules/access/vnc.c
index 22b10900fe..82b8f3c1a9 100644
--- a/modules/access/vnc.c
+++ b/modules/access/vnc.c
@@ -385,7 +385,7 @@ static int Open( vlc_object_t *p_this )
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys;
- p_sys = calloc( 1, sizeof(demux_sys_t) );
+ p_sys = vlc_calloc( p_this, 1, sizeof(demux_sys_t) );
if( !p_sys ) return VLC_ENOMEM;
p_sys->f_fps = var_InheritFloat( p_demux, CFG_PREFIX "fps" );
@@ -398,7 +398,6 @@ static int Open( vlc_object_t *p_this )
if ( !i_chroma || vlc_fourcc_IsYUV( i_chroma ) )
{
msg_Err( p_demux, "Only RGB chroma are supported" );
- free( p_sys );
return VLC_EGENERIC;
}
@@ -406,7 +405,6 @@ static int Open( vlc_object_t *p_this )
if ( !p_chroma_desc )
{
msg_Err( p_demux, "Unable to get RGB chroma description" );
- free( p_sys );
return VLC_EGENERIC;
}
@@ -421,7 +419,6 @@ static int Open( vlc_object_t *p_this )
{
msg_Dbg( p_demux, "Unable to set up client for %s",
vlc_fourcc_GetDescription( VIDEO_ES, i_chroma ) );
- free( p_sys );
return VLC_EGENERIC;
}
@@ -466,7 +463,7 @@ static int Open( vlc_object_t *p_this )
if( !rfbInitClient( p_sys->p_client, NULL, NULL ) )
{
msg_Err( p_demux, "can't connect to RFB server" );
- goto error;
+ return VLC_EGENERIC;
}
p_sys->i_starttime = mdate();
@@ -474,17 +471,13 @@ static int Open( vlc_object_t *p_this )
if ( vlc_clone( &p_sys->thread, DemuxThread, p_demux, VLC_THREAD_PRIORITY_INPUT ) != VLC_SUCCESS )
{
msg_Err( p_demux, "can't spawn thread" );
- goto error;
+ return VLC_EGENERIC;
}
p_demux->pf_demux = NULL;
p_demux->pf_control = Control;
return VLC_SUCCESS;
-
-error:
- free( p_sys );
- return VLC_EGENERIC;
}
/*****************************************************************************
@@ -505,6 +498,4 @@ static void Close( vlc_object_t *p_this )
if ( p_sys->p_block )
block_Release( p_sys->p_block );
-
- free( p_sys );
}
diff --git a/modules/access/wasapi.c b/modules/access/wasapi.c
index 491e7c292c..f7b8c6683f 100644
--- a/modules/access/wasapi.c
+++ b/modules/access/wasapi.c
@@ -388,7 +388,7 @@ static int Open(vlc_object_t *obj)
if (demux->psz_location != NULL && *demux->psz_location != '\0')
return VLC_EGENERIC; /* TODO non-default device */
- demux_sys_t *sys = malloc(sizeof (*sys));
+ demux_sys_t *sys = vlc_malloc(obj, sizeof (*sys));
if (unlikely(sys == NULL))
return VLC_ENOMEM;
@@ -460,7 +460,6 @@ error:
for (unsigned i = 0; i < 2; i++)
if (sys->events[i] != NULL)
CloseHandle(sys->events[i]);
- free(sys);
return VLC_ENOMEM;
}
@@ -482,7 +481,6 @@ static void Close (vlc_object_t *obj)
CoUninitialize();
for (unsigned i = 0; i < 2; i++)
CloseHandle(sys->events[i]);
- free(sys);
}
#define LOOPBACK_TEXT N_("Loopback mode")
More information about the vlc-commits
mailing list