Commit bf51e088 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

objres: restore malloc() wrapper

Regression from cf4676c1.
parent e3a9edee
......@@ -67,7 +67,7 @@ VLC_API char *vlc_object_get_name( const vlc_object_t * ) VLC_USED;
#define vlc_list_children(a) \
vlc_list_children( VLC_OBJECT(a) )
VLC_API VLC_MALLOC void *vlc_obj_alloc(vlc_object_t *, size_t, size_t);
VLC_API VLC_MALLOC void *vlc_obj_malloc(vlc_object_t *, size_t);
VLC_API VLC_MALLOC void *vlc_obj_calloc(vlc_object_t *, size_t, size_t);
VLC_API void vlc_obj_free(vlc_object_t *, void *);
......
......@@ -341,7 +341,7 @@ static uint16_t channel_maps[] = {
static int Open (vlc_object_t *obj)
{
demux_t *demux = (demux_t *)obj;
demux_sys_t *sys = vlc_obj_alloc(obj, 1, sizeof (*sys));
demux_sys_t *sys = vlc_obj_malloc(obj, sizeof (*sys));
if (unlikely(sys == NULL))
return VLC_ENOMEM;
......
......@@ -73,7 +73,7 @@ static int Open(vlc_object_t *object)
if (!input)
return VLC_EGENERIC;
access_sys_t *sys = vlc_obj_alloc(object, 1, sizeof (*sys));
access_sys_t *sys = vlc_obj_malloc(object, sizeof (*sys));
if (unlikely(sys == NULL))
return VLC_ENOMEM;
......
......@@ -83,7 +83,7 @@ struct sout_access_out_sys_t {
int OpenAvio(vlc_object_t *object)
{
stream_t *access = (stream_t*)object;
access_sys_t *sys = vlc_obj_alloc(object, 1, sizeof(*sys));
access_sys_t *sys = vlc_obj_malloc(object, sizeof(*sys));
if (!sys)
return VLC_ENOMEM;
sys->context = NULL;
......@@ -159,7 +159,7 @@ int OutOpenAvio(vlc_object_t *object)
config_ChainParse( access, "sout-avio-", ppsz_sout_options, access->p_cfg );
sout_access_out_sys_t *sys = vlc_obj_alloc(object, 1, sizeof(*sys));
sout_access_out_sys_t *sys = vlc_obj_malloc(object, sizeof(*sys));
if (!sys)
return VLC_ENOMEM;
sys->context = NULL;
......
......@@ -225,7 +225,7 @@ static int DemuxOpen(vlc_object_t *obj)
if (track == 0 /* Whole disc -> use access plugin */)
goto error;
demux_sys_t *sys = vlc_obj_alloc(obj, 1, sizeof (*sys));
demux_sys_t *sys = vlc_obj_malloc(obj, sizeof (*sys));
if (unlikely(sys == NULL))
goto error;
......@@ -619,7 +619,7 @@ static int AccessOpen(vlc_object_t *obj)
return VLC_EGENERIC;
}
access_sys_t *sys = vlc_obj_alloc(obj, 1, sizeof (*sys));
access_sys_t *sys = vlc_obj_malloc(obj, sizeof (*sys));
if (unlikely(sys == NULL))
{
ioctl_Close(obj, dev);
......
......@@ -188,7 +188,7 @@ static int Open(vlc_object_t *obj)
if (list == NULL)
return VLC_EGENERIC;
access_sys_t *sys = vlc_obj_alloc(obj, 1, sizeof (*sys));
access_sys_t *sys = vlc_obj_malloc(obj, sizeof (*sys));
if (unlikely(sys == NULL))
{
free(list);
......
......@@ -53,7 +53,7 @@ struct access_sys_t
*****************************************************************************/
int DirInit (stream_t *access, DIR *dir)
{
access_sys_t *sys = vlc_obj_alloc(VLC_OBJECT(access), 1, sizeof (*sys));
access_sys_t *sys = vlc_obj_malloc(VLC_OBJECT(access), sizeof (*sys));
if (unlikely(sys == NULL))
goto error;
......
......@@ -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 = vlc_obj_alloc( p_this, 1, sizeof( access_sys_t ) );
p_access->p_sys = p_sys = vlc_obj_malloc( p_this, sizeof( *p_sys ) );
if( !p_sys )
return VLC_EGENERIC;
......
......@@ -205,7 +205,7 @@ int FileOpen( vlc_object_t *p_this )
#endif
}
access_sys_t *p_sys = vlc_obj_alloc(p_this, 1, sizeof (*p_sys));
access_sys_t *p_sys = vlc_obj_malloc(p_this, sizeof (*p_sys));
if (unlikely(p_sys == NULL))
goto error;
p_access->pf_read = Read;
......
......@@ -156,7 +156,7 @@ static int Open( vlc_object_t *p_this )
int ret = VLC_EGENERIC;
vlc_credential credential;
access_sys_t *p_sys = vlc_obj_alloc( p_this, 1, sizeof(*p_sys) );
access_sys_t *p_sys = vlc_obj_malloc( p_this, sizeof(*p_sys) );
if( unlikely(p_sys == NULL) )
return VLC_ENOMEM;
......
......@@ -184,7 +184,7 @@ nop:
if( length == 0 )
goto nop; /* avoid division by zero */
demux_sys_t *p_sys = vlc_obj_alloc( p_this, 1, sizeof( *p_sys ) );
demux_sys_t *p_sys = vlc_obj_malloc( p_this, sizeof( *p_sys ) );
if( p_sys == NULL )
return VLC_ENOMEM;
......
......@@ -112,7 +112,7 @@ static int Open(vlc_object_t *object)
{
stream_t *access = (stream_t *)object;
access_sys_t *sys = vlc_obj_alloc(object, 1, sizeof (*sys));
access_sys_t *sys = vlc_obj_malloc(object, sizeof (*sys));
if (unlikely(sys == NULL))
return VLC_ENOMEM;
......
......@@ -255,7 +255,7 @@ static int Open(vlc_object_t *obj)
{
demux_t *demux = (demux_t *)obj;
demux_sys_t *sys = vlc_obj_alloc(obj, 1, sizeof (*sys));
demux_sys_t *sys = vlc_obj_malloc(obj, sizeof (*sys));
if (unlikely(sys == NULL))
return VLC_ENOMEM;
......
......@@ -55,7 +55,7 @@ static int Open (vlc_object_t *obj)
stream_t *access = (stream_t *)obj;
size_t len = strlen (access->psz_location);
access_sys_t *sys = vlc_obj_alloc(obj, 1, sizeof(*sys) + len);
access_sys_t *sys = vlc_obj_malloc(obj, sizeof(*sys) + len);
if (unlikely(sys == NULL))
return VLC_ENOMEM;
......
......@@ -138,7 +138,7 @@ struct demux_sys_t
static int Open (vlc_object_t *obj)
{
demux_t *demux = (demux_t *)obj;
demux_sys_t *sys = vlc_obj_alloc(obj, 1, sizeof (*sys));
demux_sys_t *sys = vlc_obj_malloc(obj, sizeof (*sys));
if (unlikely(sys == NULL))
return VLC_ENOMEM;
......
......@@ -172,7 +172,7 @@ static int Open(vlc_object_t *p_this)
}, *res = NULL;
int stat;
p_sys = vlc_obj_alloc( p_this, 1, sizeof( *p_sys ) );
p_sys = vlc_obj_malloc( p_this, sizeof( *p_sys ) );
if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
......
......@@ -167,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 = vlc_obj_alloc(obj, 1, sizeof (*sys));
demux_sys_t *sys = vlc_obj_malloc(obj, sizeof (*sys));
if (unlikely(sys == NULL))
return VLC_ENOMEM;
......
......@@ -100,7 +100,7 @@ static int Open( vlc_object_t *p_this )
if( p_access->b_preparsing )
return VLC_EGENERIC;
sys = vlc_obj_alloc( p_this, 1, sizeof( *sys ) );
sys = vlc_obj_malloc( p_this, sizeof( *sys ) );
if( unlikely( sys == NULL ) )
return VLC_ENOMEM;
......
......@@ -387,7 +387,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 = vlc_obj_alloc(obj, 1, sizeof (*sys));
demux_sys_t *sys = vlc_obj_malloc(obj, sizeof (*sys));
if (unlikely(sys == NULL))
return VLC_ENOMEM;
......
......@@ -75,8 +75,8 @@ static int Create( vlc_object_t *p_this )
if ( p_filter->fmt_in.video.i_chroma != VLC_CODEC_I420_10L)
return -1;
filter_sys_t *p_sys = vlc_obj_alloc( VLC_OBJECT( p_filter ), 1,
sizeof(filter_sys_t) );
filter_sys_t *p_sys = vlc_obj_malloc( VLC_OBJECT( p_filter ),
sizeof(*p_sys) );
if (!p_sys)
return VLC_ENOMEM;
......
......@@ -89,8 +89,8 @@ static int Create( vlc_object_t *p_this )
return -1;
}
filter_sys_t *p_sys = vlc_obj_alloc( VLC_OBJECT( p_filter ), 1,
sizeof(filter_sys_t) );
filter_sys_t *p_sys = vlc_obj_malloc( VLC_OBJECT( p_filter ),
sizeof(*p_sys) );
if (!p_sys)
return VLC_ENOMEM;
......
......@@ -183,7 +183,7 @@ static int Open(vlc_object_t *this)
goto bailout;
struct gl_sys *glsys = sys->gl->sys =
vlc_obj_alloc(this, 1, sizeof(struct gl_sys));
vlc_obj_malloc(this, sizeof(struct gl_sys));
if (unlikely(!sys->gl->sys))
goto bailout;
glsys->glESView = sys->glESView;
......
......@@ -275,7 +275,7 @@ vlc_LogSet
vlc_vaLog
vlc_strerror
vlc_strerror_c
vlc_obj_alloc
vlc_obj_malloc
vlc_obj_calloc
vlc_obj_free
msleep
......
......@@ -133,6 +133,14 @@ static bool ptrcmp(void *a, void *b)
return a == b;
}
void *vlc_obj_malloc(vlc_object_t *obj, size_t size)
{
void *ptr = vlc_objres_new(size, dummy_release);
if (likely(ptr != NULL))
vlc_objres_push(obj, ptr);
return ptr;
}
static void *vlc_obj_alloc_common(vlc_object_t *obj, size_t nmemb, size_t size,
bool do_memset)
{
......@@ -153,11 +161,6 @@ static void *vlc_obj_alloc_common(vlc_object_t *obj, size_t nmemb, size_t size,
return ptr;
}
void *vlc_obj_alloc(vlc_object_t *obj, size_t nmemb, size_t size)
{
return vlc_obj_alloc_common(obj, nmemb, size, false);
}
void *vlc_obj_calloc(vlc_object_t *obj, size_t nmemb, size_t size)
{
return vlc_obj_alloc_common(obj, nmemb, size, true);
......
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