diff options
author | Eugene Syromyatnikov <evgsyr@gmail.com> | 2022-05-02 03:41:09 +0200 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2022-05-02 01:41:09 +0000 |
commit | 894b9ac409a0ef29b2a3fb6af51598a9fad9ecf6 (patch) | |
tree | b4eb171c752d6bf3d1d9e3f86d710554aef36aaa | |
parent | d5efdf7c30596a399e2625a0ce4634d852a70aa5 (diff) | |
download | strace-894b9ac409a0ef29b2a3fb6af51598a9fad9ecf6.tar.gz |
tests: introduce TAIL_ALLOC_OBJECT_{CONST,VAR}_ARR
* tests/tests.h (TAIL_ALLOC_OBJECT_CONST_ARR,
TAIL_ALLOC_OBJECT_VAR_ARR): New macros.
-rw-r--r-- | tests/tests.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/tests.h b/tests/tests.h index ca8de6c30..2a47fe77e 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -226,6 +226,14 @@ void *tail_memdup(const void *, const size_t) type_name *const type_ptr = tail_alloc(sizeof(*type_ptr)) /* + * Allocate an array of the specified type at the end + * of a mapped memory region. + * Assign its address to the specified constant pointer. + */ +# define TAIL_ALLOC_OBJECT_CONST_ARR(type_name, type_ptr, cnt) \ + type_name *const type_ptr = tail_alloc(sizeof(*type_ptr) * (cnt)) + +/* * Allocate an object of the specified type at the end * of a mapped memory region. * Assign its address to the specified variable pointer. @@ -233,6 +241,14 @@ void *tail_memdup(const void *, const size_t) # define TAIL_ALLOC_OBJECT_VAR_PTR(type_name, type_ptr) \ type_name *type_ptr = tail_alloc(sizeof(*type_ptr)) +/* + * Allocate an array of the specified type at the end + * of a mapped memory region. + * Assign its address to the specified variable pointer. + */ +# define TAIL_ALLOC_OBJECT_VAR_ARR(type_name, type_ptr, cnt) \ + type_name *type_ptr = tail_alloc(sizeof(*type_ptr) * (cnt)) + /** * Fill memory (pointed by ptr, having size bytes) with different bytes (with * values starting with start and resetting every period) in order to catch |