diff options
author | Lennart Poettering <lennart@poettering.net> | 2009-06-17 23:43:50 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2009-06-17 23:43:50 +0200 |
commit | 53b87033aa04a504677d4c14b0b65caa58d16dbd (patch) | |
tree | 87bc32d0e83d8a9018fb10a7d308ae4a8ccf1f89 /src/pulse/xmalloc.h | |
parent | 550b619558f03fb9e6d5d8072b9a4b15d9e6f91f (diff) | |
parent | 75256fb671b6ae8d784e0d6415d292fdbc6482c2 (diff) |
Merge commit 'origin/master' into master-tx
Diffstat (limited to 'src/pulse/xmalloc.h')
-rw-r--r-- | src/pulse/xmalloc.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/pulse/xmalloc.h b/src/pulse/xmalloc.h index db20496f..f720d83f 100644 --- a/src/pulse/xmalloc.h +++ b/src/pulse/xmalloc.h @@ -88,9 +88,20 @@ static inline void* _pa_xnewdup_internal(const void *p, size_t n, size_t k) { return pa_xmemdup(p, n*k); } -/** Same as pa_xnew() but set the memory to zero */ +/** Same as pa_xnew() but duplicate the specified data */ #define pa_xnewdup(type, p, n) ((type*) _pa_xnewdup_internal((p), (n), sizeof(type))) +/** Internal helper for pa_xrenew() */ +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); +} + +/** Reallocate n new structures of the specified type. */ +#define pa_xrenew(type, p, n) ((type*) _pa_xrenew_internal(p, (n), sizeof(type))) + PA_C_DECL_END #endif |