[vlc-devel] [PATCH 2/2] vlc_alloc: helper for table allocation
Thomas Guillem
thomas at gllm.fr
Sat Nov 11 16:54:52 CET 2017
From: RĂ©mi Denis-Courmont <remi at remlab.net>
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
---
include/vlc_common.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/vlc_common.h b/include/vlc_common.h
index 662248ceb3..ed5ff77730 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -844,6 +844,12 @@ VLC_API bool vlc_ureduce( unsigned *, unsigned *, uint64_t, uint64_t, uint64_t )
#define container_of(ptr, type, member) \
((type *)(((char *)(ptr)) - offsetof(type, member)))
+VLC_USED VLC_MALLOC
+static inline void *vlc_alloc(size_t count, size_t size)
+{
+ return likely(count * size >= size) ? malloc(count * size) : NULL;
+}
+
/*****************************************************************************
* I18n stuff
*****************************************************************************/
--
2.11.0
More information about the vlc-devel
mailing list