]> git.sesse.net Git - vlc/blobdiff - include/vlc_common.h
xmalloc, xrealloc: traditional functions to allocate memory
[vlc] / include / vlc_common.h
index 82dad3670f8926ff09dc817c24ee164467678c02..d8dd5807a06619639439ea612f9466f2b156077e 100644 (file)
@@ -814,6 +814,25 @@ static inline const char *vlc_pgettext( const char *ctx, const char *id )
     return (tr == ctx) ? id : tr;
 }
 
+/*****************************************************************************
+ * Loosy memory allocation functions. Do not use in new code.
+ *****************************************************************************/
+static inline void *xmalloc (size_t len)
+{
+    void *ptr = malloc (len);
+    if (unlikely (ptr == NULL))
+        abort ();
+    return ptr;
+}
+
+static inline void *xrealloc (void *ptr, size_t len)
+{
+    void *nptr = realloc (ptr, len);
+    if (unlikely (nptr == NULL))
+        abort ();
+    return nptr;
+}
+
 /*****************************************************************************
  * libvlc features
  *****************************************************************************/