tests: add TAIL_ALLOC_OBJECT_{CONST,VAR}_PTR to tests.h
Introduce a new macros for the most widespread use of tail_alloc. * tests/tests.h (TAIL_ALLOC_OBJECT_CONST_PTR, TAIL_ALLOC_OBJECT_VAR_PTR): New macros.
This commit is contained in:
parent
9407d10e12
commit
72b7cfb3bf
@ -71,6 +71,22 @@ void *tail_alloc(const size_t)
|
||||
void *tail_memdup(const void *, const size_t)
|
||||
ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE((2));
|
||||
|
||||
/*
|
||||
* Allocate an object 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_PTR(type_name, type_ptr) \
|
||||
type_name *const type_ptr = tail_alloc(sizeof(*type_ptr))
|
||||
|
||||
/*
|
||||
* Allocate an object 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_PTR(type_name, type_ptr) \
|
||||
type_name *type_ptr = tail_alloc(sizeof(*type_ptr))
|
||||
|
||||
/*
|
||||
* Fill memory (pointed by ptr, having size bytes) with different bytes (with
|
||||
* values starting with start and resetting every period) in order to catch
|
||||
|
Loading…
x
Reference in New Issue
Block a user