Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Use sizeof(char) in place for sizeof(void) (#515)" #516

Merged
merged 1 commit into from
May 10, 2021
Merged
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
6 changes: 1 addition & 5 deletions demo_nodes_cpp/src/topics/allocator_tutorial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <list>
#include <memory>
#include <string>
#include <type_traits>
#include <utility>

#include "rclcpp/rclcpp.hpp"
Expand Down Expand Up @@ -57,10 +56,7 @@ struct MyAllocator
return nullptr;
}
num_allocs++;
// Use sizeof(char) in place for sizeof(void)
constexpr size_t value_size = sizeof(
typename std::conditional<!std::is_void<T>::value, T, char>::type);
return static_cast<T *>(std::malloc(size * value_size));
return static_cast<T *>(std::malloc(size * sizeof(T)));
}

void deallocate(T * ptr, size_t size)
Expand Down