[vlc-commits] objres: restore malloc() wrapper

Rémi Denis-Courmont git at videolan.org
Tue Nov 28 18:20:11 CET 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Nov 28 18:54:06 2017 +0200| [bf51e088023ae35dfba1a9b781fed853739c4a8c] | committer: Rémi Denis-Courmont

objres: restore malloc() wrapper

Regression from cf4676c1e8cdf69db4598f7d10ffdf6a695c3ba0.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bf51e088023ae35dfba1a9b781fed853739c4a8c
---

 include/vlc_objects.h               |  2 +-
 modules/access/alsa.c               |  2 +-
 modules/access/attachment.c         |  2 +-
 modules/access/avio.c               |  4 ++--
 modules/access/cdda.c               |  4 ++--
 modules/access/concat.c             |  2 +-
 modules/access/directory.c          |  2 +-
 modules/access/dv.c                 |  2 +-
 modules/access/file.c               |  2 +-
 modules/access/http.c               |  2 +-
 modules/access/idummy.c             |  2 +-
 modules/access/imem-access.c        |  2 +-
 modules/access/pulse.c              |  2 +-
 modules/access/sdp.c                |  2 +-
 modules/access/shm.c                |  2 +-
 modules/access/srt.c                |  2 +-
 modules/access/timecode.c           |  2 +-
 modules/access/udp.c                |  2 +-
 modules/access/wasapi.c             |  2 +-
 modules/video_chroma/i420_10_p010.c |  4 ++--
 modules/video_chroma/i420_nv12.c    |  4 ++--
 modules/video_output/ios.m          |  2 +-
 src/libvlccore.sym                  |  2 +-
 src/misc/objres.c                   | 13 ++++++++-----
 24 files changed, 35 insertions(+), 32 deletions(-)

diff --git a/include/vlc_objects.h b/include/vlc_objects.h
index aba548fe4b..a5b5dc21dc 100644
--- a/include/vlc_objects.h
+++ b/include/vlc_objects.h
@@ -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 *);
 
diff --git a/modules/access/alsa.c b/modules/access/alsa.c
index 3a27b32938..69777788b6 100644
--- a/modules/access/alsa.c
+++ b/modules/access/alsa.c
@@ -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;
 
diff --git a/modules/access/attachment.c b/modules/access/attachment.c
index f9a03eb3f6..9623f82369 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 = vlc_obj_alloc(object, 1, sizeof (*sys));
+    access_sys_t *sys = vlc_obj_malloc(object, sizeof (*sys));
     if (unlikely(sys == NULL))
         return VLC_ENOMEM;
 
diff --git a/modules/access/avio.c b/modules/access/avio.c
index 7e27cbc6e5..c88e812165 100644
--- a/modules/access/avio.c
+++ b/modules/access/avio.c
@@ -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;
diff --git a/modules/access/cdda.c b/modules/access/cdda.c
index 08ed2e8c3b..e52594d30d 100644
--- a/modules/access/cdda.c
+++ b/modules/access/cdda.c
@@ -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);
diff --git a/modules/access/concat.c b/modules/access/concat.c
index 998bfb7568..11c5ef3cd9 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 = vlc_obj_alloc(obj, 1, sizeof (*sys));
+    access_sys_t *sys = vlc_obj_malloc(obj, sizeof (*sys));
     if (unlikely(sys == NULL))
     {
         free(list);
diff --git a/modules/access/directory.c b/modules/access/directory.c
index e6d2f11587..59915de767 100644
--- a/modules/access/directory.c
+++ b/modules/access/directory.c
@@ -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;
 
diff --git a/modules/access/dv.c b/modules/access/dv.c
index 0037ba2989..b15b22f490 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 = 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;
 
diff --git a/modules/access/file.c b/modules/access/file.c
index bb5e5df71c..4a6213b73a 100644
--- a/modules/access/file.c
+++ b/modules/access/file.c
@@ -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;
diff --git a/modules/access/http.c b/modules/access/http.c
index 5e50f4cce5..10dd4105a5 100644
--- a/modules/access/http.c
+++ b/modules/access/http.c
@@ -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;
 
diff --git a/modules/access/idummy.c b/modules/access/idummy.c
index 2e197d7277..6721df04c7 100644
--- a/modules/access/idummy.c
+++ b/modules/access/idummy.c
@@ -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;
 
diff --git a/modules/access/imem-access.c b/modules/access/imem-access.c
index 3a61ead93a..5649cc0603 100644
--- a/modules/access/imem-access.c
+++ b/modules/access/imem-access.c
@@ -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;
 
diff --git a/modules/access/pulse.c b/modules/access/pulse.c
index c57ba2517d..4ad7477374 100644
--- a/modules/access/pulse.c
+++ b/modules/access/pulse.c
@@ -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;
 
diff --git a/modules/access/sdp.c b/modules/access/sdp.c
index 3e7b26ac39..a36c618e2e 100644
--- a/modules/access/sdp.c
+++ b/modules/access/sdp.c
@@ -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;
 
diff --git a/modules/access/shm.c b/modules/access/shm.c
index b3ed030344..ecbf0860a3 100644
--- a/modules/access/shm.c
+++ b/modules/access/shm.c
@@ -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;
 
diff --git a/modules/access/srt.c b/modules/access/srt.c
index 485c206902..35f76528e1 100644
--- a/modules/access/srt.c
+++ b/modules/access/srt.c
@@ -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;
 
diff --git a/modules/access/timecode.c b/modules/access/timecode.c
index c26b7ceacf..3f962c5dce 100644
--- a/modules/access/timecode.c
+++ b/modules/access/timecode.c
@@ -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;
diff --git a/modules/access/udp.c b/modules/access/udp.c
index 9677f8279f..cf6ebb7125 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 = vlc_obj_alloc( p_this, 1, sizeof( *sys ) );
+    sys = vlc_obj_malloc( p_this, sizeof( *sys ) );
     if( unlikely( sys == NULL ) )
         return VLC_ENOMEM;
 
diff --git a/modules/access/wasapi.c b/modules/access/wasapi.c
index 0db2a22121..fe162c7909 100644
--- a/modules/access/wasapi.c
+++ b/modules/access/wasapi.c
@@ -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;
 
diff --git a/modules/video_chroma/i420_10_p010.c b/modules/video_chroma/i420_10_p010.c
index 079e831bb9..a13104736f 100644
--- a/modules/video_chroma/i420_10_p010.c
+++ b/modules/video_chroma/i420_10_p010.c
@@ -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;
 
diff --git a/modules/video_chroma/i420_nv12.c b/modules/video_chroma/i420_nv12.c
index 6a55616879..b08f7ecd19 100644
--- a/modules/video_chroma/i420_nv12.c
+++ b/modules/video_chroma/i420_nv12.c
@@ -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;
 
diff --git a/modules/video_output/ios.m b/modules/video_output/ios.m
index 0740c2624c..67898521ab 100644
--- a/modules/video_output/ios.m
+++ b/modules/video_output/ios.m
@@ -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;
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 7c99021ae4..3e0d23fdf0 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -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
diff --git a/src/misc/objres.c b/src/misc/objres.c
index 5ff390901f..843ba40056 100644
--- a/src/misc/objres.c
+++ b/src/misc/objres.c
@@ -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);



More information about the vlc-commits mailing list