[vlc-devel] [PATCH] Remove VLC_MALLOC attribute on vlc_custom_create()
Romain Vimont
rom1v at videolabs.io
Wed Apr 18 10:23:45 CEST 2018
VLC_MALLOC is defined as follow:
#define VLC_MALLOC __attribute__ ((malloc))
The documentation about "__attribute__ ((malloc))" says:
> This tells the compiler that a function is malloc-like, i.e., that the
> pointer P returned by the function cannot alias any other pointer
> valid when the function returns, and moreover no pointers to valid
> objects occur in any storage addressed by P.
>
> Using this attribute can improve optimization. Functions like malloc
> and calloc have this property because they return a pointer to
> uninitialized or zeroed-out storage. However, functions like realloc
> do not have this property, as they can return a pointer to storage
> containing pointers.
<https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes>
The vlc_custom_create() implementation does not respect "no pointers to
valid objects occur in any storage addressed by P" (in particular,
obj->obj.parent points to a valid object).
> However, functions like realloc do not have this property, as they can
> return a pointer to storage containing pointers.
Here, vlc_custom_create() returns a pointer to storage containing
pointers.
---
This is just for discussion. It is possible that I misunderstood the
documentation (I didn't know this flag).
include/vlc_objects.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/vlc_objects.h b/include/vlc_objects.h
index 4e0314acbb..e7996f7d39 100644
--- a/include/vlc_objects.h
+++ b/include/vlc_objects.h
@@ -114,7 +114,7 @@ struct libvlc_int_t
/*****************************************************************************
* Prototypes
*****************************************************************************/
-VLC_API void *vlc_object_create( vlc_object_t *, size_t ) VLC_MALLOC VLC_USED;
+VLC_API void *vlc_object_create( vlc_object_t *, size_t ) VLC_USED;
VLC_API vlc_object_t *vlc_object_find_name( vlc_object_t *, const char * ) VLC_USED VLC_DEPRECATED;
VLC_API void * vlc_object_hold( vlc_object_t * );
VLC_API void vlc_object_release( vlc_object_t * );
--
2.17.0
More information about the vlc-devel
mailing list