[vlc-devel] [PATCH] vlc_talloc: helper for table allocation

RĂ©mi Denis-Courmont remi at remlab.net
Sat Nov 11 16:16:39 CET 2017


---
 include/vlc_common.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/vlc_common.h b/include/vlc_common.h
index 662248ceb3..3f03022e9f 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_talloc(size_t count, size_t size)
+{
+    return likely(count * size >= size) ? malloc(count * size) : NULL;
+}
+
 /*****************************************************************************
  * I18n stuff
  *****************************************************************************/
-- 
2.15.0



More information about the vlc-devel mailing list