23 #include <sys/types.h>
28 #include <pulse/cdecl.h>
30 #include <pulse/version.h>
62 static inline void* _pa_xnew_internal(
size_t n,
size_t k) {
63 assert(n < INT_MAX/k);
68 #define pa_xnew(type, n) ((type*) _pa_xnew_internal((n), sizeof(type)))
73 static inline void* _pa_xnew0_internal(
size_t n,
size_t k) {
74 assert(n < INT_MAX/k);
79 #define pa_xnew0(type, n) ((type*) _pa_xnew0_internal((n), sizeof(type)))
84 static inline void* _pa_xnewdup_internal(
const void *p,
size_t n,
size_t k) {
85 assert(n < INT_MAX/k);
90 #define pa_xnewdup(type, p, n) ((type*) _pa_xnewdup_internal((p), (n), sizeof(type)))
95 static inline void* _pa_xrenew_internal(
void *p,
size_t n,
size_t k) {
96 assert(n < INT_MAX/k);
101 #define pa_xrenew(type, p, n) ((type*) _pa_xrenew_internal(p, (n), sizeof(type)))
#define PA_GCC_MALLOC
Macro for usage of GCC's malloc attribute.
Definition: gccmacro.h:119
#define PA_GCC_ALLOC_SIZE(x)
Macro for usage of GCC's alloc_size attribute.
Definition: gccmacro.h:108
#define PA_GCC_ALLOC_SIZE2(x, y)
Macro for usage of GCC's alloc_size attribute.
Definition: gccmacro.h:110
char * pa_xstrndup(const char *s, size_t l) PA_GCC_MALLOC
Duplicate the specified string, but truncate after l characters.
void * pa_xrealloc(void *ptr, size_t size) PA_GCC_ALLOC_SIZE(2)
The combination of pa_xmalloc() and realloc()
void * pa_xmalloc0(size_t l) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE(1)
Same as pa_xmalloc(), but initialize allocated memory to 0.
char * pa_xstrdup(const char *s) PA_GCC_MALLOC
Duplicate the specified string, allocating memory with pa_xmalloc()
void pa_xfree(void *p)
Free allocated memory.
void * pa_xmemdup(const void *p, size_t l) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE(2)
Duplicate the specified memory block.
void * pa_xmalloc(size_t l) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE(1)
Allocate the specified number of bytes, just like malloc() does.