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