From: RĂ©mi Denis-Courmont Date: Sun, 6 Dec 2009 08:46:29 +0000 (+0200) Subject: xmalloc, xrealloc: traditional functions to allocate memory X-Git-Tag: 1.1.0-ff~2169 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=95a993e5f486beda44c05e5fabf72a2c4bfb3bee;p=vlc xmalloc, xrealloc: traditional functions to allocate memory Those functions automatically abort if allocation fails (which is not quite the same as calling assert()). Avoid these functions in new code. --- diff --git a/include/vlc_common.h b/include/vlc_common.h index 82dad3670f..d8dd5807a0 100644 --- a/include/vlc_common.h +++ b/include/vlc_common.h @@ -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 *****************************************************************************/