mirror of
https://code.videolan.org/videolan/vlc
synced 2024-09-28 23:09:59 +02:00
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.
This commit is contained in:
parent
827b111356
commit
95a993e5f4
@ -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
|
||||
*****************************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user