123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- #ifndef foomemoryhfoo
- #define foomemoryhfoo
- #include <sys/types.h>
- #include <stdlib.h>
- #include <limits.h>
- #include <assert.h>
- #include <pulse/cdecl.h>
- #include <pulse/gccmacro.h>
- #include <pulse/version.h>
- PA_C_DECL_BEGIN
- void* pa_xmalloc(size_t l) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE(1);
- void *pa_xmalloc0(size_t l) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE(1);
- void *pa_xrealloc(void *ptr, size_t size) PA_GCC_ALLOC_SIZE(2);
- void pa_xfree(void *p);
- char *pa_xstrdup(const char *s) PA_GCC_MALLOC;
- char *pa_xstrndup(const char *s, size_t l) PA_GCC_MALLOC;
- void* pa_xmemdup(const void *p, size_t l) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE(2);
- static void* _pa_xnew_internal(size_t n, size_t k) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE2(1,2);
- static inline void* _pa_xnew_internal(size_t n, size_t k) {
- assert(n < INT_MAX/k);
- return pa_xmalloc(n*k);
- }
- #define pa_xnew(type, n) ((type*) _pa_xnew_internal((n), sizeof(type)))
- static void* _pa_xnew0_internal(size_t n, size_t k) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE2(1,2);
- static inline void* _pa_xnew0_internal(size_t n, size_t k) {
- assert(n < INT_MAX/k);
- return pa_xmalloc0(n*k);
- }
- #define pa_xnew0(type, n) ((type*) _pa_xnew0_internal((n), sizeof(type)))
- static void* _pa_xnewdup_internal(const void *p, size_t n, size_t k) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE2(2,3);
- static inline void* _pa_xnewdup_internal(const void *p, size_t n, size_t k) {
- assert(n < INT_MAX/k);
- return pa_xmemdup(p, n*k);
- }
- #define pa_xnewdup(type, p, n) ((type*) _pa_xnewdup_internal((p), (n), sizeof(type)))
- static void* _pa_xrenew_internal(void *p, size_t n, size_t k) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE2(2,3);
- static inline void* _pa_xrenew_internal(void *p, size_t n, size_t k) {
- assert(n < INT_MAX/k);
- return pa_xrealloc(p, n*k);
- }
- #define pa_xrenew(type, p, n) ((type*) _pa_xrenew_internal(p, (n), sizeof(type)))
- PA_C_DECL_END
- #endif
|