Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion include/rcutils/allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ extern "C"
* until all uses of the allocator have been made.
* Particular care should be taken when giving an allocator to functions like
* rcutils_*_init() where it is stored within another object and used later.
* Developers should note that, while the fields of a const-qualified allocator
* struct cannot be modified, the state of the allocator can be modified.
*/
typedef struct rcutils_allocator_t
{
Expand All @@ -64,7 +66,11 @@ typedef struct rcutils_allocator_t
/** An error should be indicated by returning `NULL`. */
void * (*zero_allocate)(size_t number_of_elements, size_t size_of_element, void * state);
/// Implementation defined state storage.
/** This is passed as the final parameter to other allocator functions. */
/**
* This is passed as the final parameter to other allocator functions.
* Note that the contents of the state can be modified even in const-qualified
* allocator objects.
*/
void * state;
} rcutils_allocator_t;

Expand Down
2 changes: 1 addition & 1 deletion include/rcutils/repl_str.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ rcutils_repl_str(
const char * str,
const char * from,
const char * to,
rcutils_allocator_t * allocator);
const rcutils_allocator_t * allocator);

// Implementation copied from above mentioned source continues in repl_str.c.

Expand Down
2 changes: 1 addition & 1 deletion include/rcutils/types/string_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ rcutils_ret_t
rcutils_string_array_init(
rcutils_string_array_t * string_array,
size_t size,
rcutils_allocator_t * allocator);
const rcutils_allocator_t * allocator);

/// Finalize a string array, reclaiming all resources.
/**
Expand Down
2 changes: 1 addition & 1 deletion src/repl_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ rcutils_repl_str(
const char * str,
const char * from,
const char * to,
rcutils_allocator_t * allocator)
const rcutils_allocator_t * allocator)
{
/* Adjust each of the below values to suit your needs. */

Expand Down
2 changes: 1 addition & 1 deletion src/string_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ rcutils_ret_t
rcutils_string_array_init(
rcutils_string_array_t * string_array,
size_t size,
rcutils_allocator_t * allocator)
const rcutils_allocator_t * allocator)
{
if (!allocator) {
RCUTILS_SET_ERROR_MSG("allocator is null", rcutils_get_default_allocator())
Expand Down