PulseAudio  16.0
xmalloc.h File Reference

Memory allocation functions. More...

Go to the source code of this file.

Macros

#define pa_xnew(type, n)   ((type*) _pa_xnew_internal((n), sizeof(type)))
 Allocate n new structures of the specified type. More...
 
#define pa_xnew0(type, n)   ((type*) _pa_xnew0_internal((n), sizeof(type)))
 Same as pa_xnew() but set the memory to zero. More...
 
#define pa_xnewdup(type, p, n)   ((type*) _pa_xnewdup_internal((p), (n), sizeof(type)))
 Same as pa_xnew() but duplicate the specified data. More...
 
#define pa_xrenew(type, p, n)   ((type*) _pa_xrenew_internal(p, (n), sizeof(type)))
 Reallocate n new structures of the specified type. More...
 

Functions

void * pa_xmalloc (size_t l) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE(1)
 Allocate the specified number of bytes, just like malloc() does. More...
 
void * pa_xmalloc0 (size_t l) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE(1)
 Same as pa_xmalloc(), but initialize allocated memory to 0. More...
 
void * pa_xrealloc (void *ptr, size_t size) PA_GCC_ALLOC_SIZE(2)
 The combination of pa_xmalloc() and realloc() More...
 
void pa_xfree (void *p)
 Free allocated memory. More...
 
char * pa_xstrdup (const char *s) PA_GCC_MALLOC
 Duplicate the specified string, allocating memory with pa_xmalloc() More...
 
char * pa_xstrndup (const char *s, size_t l) PA_GCC_MALLOC
 Duplicate the specified string, but truncate after l characters. More...
 
void * pa_xmemdup (const void *p, size_t l) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE(2)
 Duplicate the specified memory block. More...
 

Detailed Description

Memory allocation functions.

Macro Definition Documentation

◆ pa_xnew

#define pa_xnew (   type,
 
)    ((type*) _pa_xnew_internal((n), sizeof(type)))

Allocate n new structures of the specified type.

◆ pa_xnew0

#define pa_xnew0 (   type,
 
)    ((type*) _pa_xnew0_internal((n), sizeof(type)))

Same as pa_xnew() but set the memory to zero.

◆ pa_xnewdup

#define pa_xnewdup (   type,
  p,
 
)    ((type*) _pa_xnewdup_internal((p), (n), sizeof(type)))

Same as pa_xnew() but duplicate the specified data.

◆ pa_xrenew

#define pa_xrenew (   type,
  p,
 
)    ((type*) _pa_xrenew_internal(p, (n), sizeof(type)))

Reallocate n new structures of the specified type.

Function Documentation

◆ pa_xfree()

void pa_xfree ( void *  p)

Free allocated memory.

◆ pa_xmalloc()

void* pa_xmalloc ( size_t  l)

Allocate the specified number of bytes, just like malloc() does.

However, in case of OOM, terminate

◆ pa_xmalloc0()

void* pa_xmalloc0 ( size_t  l)

Same as pa_xmalloc(), but initialize allocated memory to 0.

◆ pa_xmemdup()

void* pa_xmemdup ( const void *  p,
size_t  l 
)

Duplicate the specified memory block.

◆ pa_xrealloc()

void* pa_xrealloc ( void *  ptr,
size_t  size 
)

The combination of pa_xmalloc() and realloc()

◆ pa_xstrdup()

char* pa_xstrdup ( const char *  s)

Duplicate the specified string, allocating memory with pa_xmalloc()

◆ pa_xstrndup()

char* pa_xstrndup ( const char *  s,
size_t  l 
)

Duplicate the specified string, but truncate after l characters.