Skip to content

Commit

Permalink
Replace rcutils_allocator with the system allocator
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolai Morin <[email protected]>
  • Loading branch information
nnmm committed Mar 8, 2022
1 parent d5d0b1a commit c48741a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
6 changes: 2 additions & 4 deletions rosidl_generator_c/resource/msg__functions.c.em
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,8 @@ bool
if (output->capacity < input->size) {
const size_t allocation_size =
input->size * sizeof(@(message_typename));
rcutils_allocator_t allocator = rcutils_get_default_allocator();
@(message_typename) * data =
(@(message_typename) *)allocator.reallocate(
output->data, allocation_size, allocator.state);
(@(message_typename) *)realloc(output->data, allocation_size);
if (!data) {
return false;
}
Expand All @@ -469,7 +467,7 @@ bool
for (; i-- > output->capacity; ) {
@(message_typename)__fini(&data[i]);
}
allocator.deallocate(data, allocator.state);
free(data);
return false;
}
}
Expand Down
5 changes: 2 additions & 3 deletions rosidl_runtime_c/src/primitives_sequence_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@
return false; \
} \
if (output->capacity < input->size) { \
rcutils_allocator_t allocator = rcutils_get_default_allocator(); \
TYPE_NAME * data = (TYPE_NAME *)allocator.reallocate( \
output->data, sizeof(TYPE_NAME) * input->size, allocator.state); \
TYPE_NAME * data = (TYPE_NAME *)realloc( \
output->data, sizeof(TYPE_NAME) * input->size); \
if (!data) { \
return false; \
} \
Expand Down
6 changes: 2 additions & 4 deletions rosidl_runtime_c/src/string_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,8 @@ rosidl_runtime_c__String__Sequence__copy(
if (output->capacity < input->size) {
const size_t allocation_size =
input->size * sizeof(rosidl_runtime_c__String);
rcutils_allocator_t allocator = rcutils_get_default_allocator();
rosidl_runtime_c__String * data =
(rosidl_runtime_c__String *)allocator.reallocate(
output->data, allocation_size, allocator.state);
(rosidl_runtime_c__String *)realloc(output->data, allocation_size);
if (!data) {
return false;
}
Expand All @@ -242,7 +240,7 @@ rosidl_runtime_c__String__Sequence__copy(
for (; i-- > output->capacity; ) {
rosidl_runtime_c__String__fini(&data[i]);
}
allocator.deallocate(data, allocator.state);
free(data);
return false;
}
}
Expand Down
6 changes: 2 additions & 4 deletions rosidl_runtime_c/src/u16string_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,8 @@ rosidl_runtime_c__U16String__Sequence__copy(
if (output->capacity < input->size) {
const size_t size =
input->size * sizeof(rosidl_runtime_c__U16String);
rcutils_allocator_t allocator = rcutils_get_default_allocator();
rosidl_runtime_c__U16String * data =
(rosidl_runtime_c__U16String *)allocator.reallocate(
output->data, size, allocator.state);
(rosidl_runtime_c__U16String *)realloc(output->data, size);
if (!data) {
return false;
}
Expand All @@ -285,7 +283,7 @@ rosidl_runtime_c__U16String__Sequence__copy(
for (; i-- > output->capacity; ) {
rosidl_runtime_c__U16String__fini(&data[i]);
}
allocator.deallocate(data, allocator.state);
free(data);
return false;
}
}
Expand Down

0 comments on commit c48741a

Please sign in to comment.