Skip to content

Commit

Permalink
Revert "Use sizeof(char) in place for sizeof(void) (#515)" (#516)
Browse files Browse the repository at this point in the history
This reverts commit c3769dd.

Signed-off-by: Michel Hidalgo <[email protected]>
  • Loading branch information
hidmic authored May 10, 2021
1 parent 593e05e commit 1c0d891
Showing 1 changed file with 1 addition and 5 deletions.
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

0 comments on commit 1c0d891

Please sign in to comment.