rcutils
master
C API providing common utilities and data structures.
|
Go to the documentation of this file.
17 #ifndef RCUTILS__ALLOCATOR_H_
18 #define RCUTILS__ALLOCATOR_H_
51 void * (*allocate)(
size_t size,
void *
state);
66 void * (*reallocate)(
void * pointer,
size_t size,
void *
state);
69 void * (*zero_allocate)(
size_t number_of_elements,
size_t size_of_element,
void *
state);
122 #define RCUTILS_CHECK_ALLOCATOR(allocator, fail_statement) \
123 if (!rcutils_allocator_is_valid(allocator)) { \
128 #define RCUTILS_CHECK_ALLOCATOR_WITH_MSG(allocator, msg, fail_statement) \
129 if (!rcutils_allocator_is_valid(allocator)) { \
130 RCUTILS_SET_ERROR_MSG(msg); \
151 #endif // RCUTILS__ALLOCATOR_H_
rcutils_allocator_t rcutils_get_default_allocator(void)
Return a properly initialized rcutils_allocator_t with default values.
bool rcutils_allocator_is_valid(const rcutils_allocator_t *allocator)
Return true if the given allocator has non-null function pointers.
struct rcutils_allocator_t rcutils_allocator_t
Encapsulation of an allocator.
void * rcutils_reallocf(void *pointer, size_t size, rcutils_allocator_t *allocator)
Emulate the behavior of reallocf.
#define RCUTILS_WARN_UNUSED
A macro to make the compiler warn when the return value of a function is not used.
Definition: macros.h:27
rcutils_allocator_t rcutils_get_zero_initialized_allocator(void)
Return a zero initialized allocator.
Encapsulation of an allocator.
Definition: allocator.h:47
#define RCUTILS_PUBLIC
Definition: visibility_control.h:23
void * state
Implementation defined state storage.
Definition: allocator.h:76
void(* deallocate)(void *pointer, void *state)
Deallocate previously allocated memory, mimicking free().
Definition: allocator.h:54