[vlc-commits] core: add vlc_alloc: helper for table allocation

Rémi Denis-Courmont git at videolan.org
Sat Nov 11 17:21:57 CET 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Nov 11 17:16:39 2017 +0200| [f5e485d1e3fe7c021c4fd740fa047fc9a28ca17e] | committer: Thomas Guillem

core: add vlc_alloc: helper for table allocation

Signed-off-by: Thomas Guillem <thomas at gllm.fr>

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

 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
  *****************************************************************************/



More information about the vlc-commits mailing list