25 #include <sys/types.h>
30 #include <pulse/cdecl.h>
64 static inline void* _pa_xnew_internal(
size_t n,
size_t k) {
65 assert(n < INT_MAX/k);
70 #define pa_xnew(type, n) ((type*) _pa_xnew_internal((n), sizeof(type)))
75 static inline void* _pa_xnew0_internal(
size_t n,
size_t k) {
76 assert(n < INT_MAX/k);
81 #define pa_xnew0(type, n) ((type*) _pa_xnew0_internal((n), sizeof(type)))
86 static inline void* _pa_xnewdup_internal(
const void *p,
size_t n,
size_t k) {
87 assert(n < INT_MAX/k);
92 #define pa_xnewdup(type, p, n) ((type*) _pa_xnewdup_internal((p), (n), sizeof(type)))
97 static inline void* _pa_xrenew_internal(
void *p,
size_t n,
size_t k) {
98 assert(n < INT_MAX/k);
103 #define pa_xrenew(type, p, n) ((type*) _pa_xrenew_internal(p, (n), sizeof(type)))
void * pa_xmemdup(const void *p, size_t l) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE(2)
Duplicate the specified memory block.
void * pa_xmalloc0(size_t l) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE(1)
Same as pa_xmalloc(), but initialize allocated memory to 0.
void pa_xfree(void *p)
Free allocated memory.
void * pa_xmalloc(size_t l) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE(1)
Allocate the specified number of bytes, just like malloc() does.
char * pa_xstrdup(const char *s) PA_GCC_MALLOC
Duplicate the specified string, allocating memory with pa_xmalloc()
#define PA_GCC_MALLOC
Macro for usage of GCC's malloc attribute.
Definition: gccmacro.h:123
void * pa_xrealloc(void *ptr, size_t size) PA_GCC_ALLOC_SIZE(2)
The combination of pa_xmalloc() and realloc()
char * pa_xstrndup(const char *s, size_t l) PA_GCC_MALLOC
Duplicate the specified string, but truncate after l characters.
#define PA_GCC_ALLOC_SIZE2(x, y)
Macro for usage of GCC's alloc_size attribute.
Definition: gccmacro.h:114
#define PA_GCC_ALLOC_SIZE(x)
Macro for usage of GCC's alloc_size attribute.
Definition: gccmacro.h:112