Skip to content

Commit

Permalink
Fixed style issues
Browse files Browse the repository at this point in the history
Signed-off-by: Ali Ashkani Nia <[email protected]>
  • Loading branch information
AliAshkaniNia committed Oct 7, 2023
1 parent 0e662e5 commit 1db7277
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions demo_nodes_cpp/src/topics/allocator_tutorial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
#include <chrono>
#include <list>
#include <memory>
#include <memory_resource>
#include <string>
#include <utility>
#include <memory_resource>

#include "rclcpp/rclcpp.hpp"
#include "rclcpp/allocator/allocator_common.hpp"
Expand All @@ -30,24 +30,29 @@ using namespace std::chrono_literals;
static uint32_t num_allocs = 0;
static uint32_t num_deallocs = 0;
// A very simple custom memory resource. Counts calls to do_allocate and do_deallocate.
class CustomMemoryResource : public std::pmr::memory_resource {
class CustomMemoryResource : public std::pmr::memory_resource
{
private:
void* do_allocate(std::size_t bytes, std::size_t alignment) override {
void * do_allocate(std::size_t bytes, std::size_t alignment) override
{
num_allocs++;
(void)alignment;
return std::malloc(bytes);
}

void do_deallocate(void* p, std::size_t bytes,
std::size_t alignment) override {
void do_deallocate(
void * p, std::size_t bytes,
std::size_t alignment) override
{
num_deallocs++;
(void)bytes;
(void)alignment;
std::free(p);
}

bool do_is_equal(
const std::pmr::memory_resource& other) const noexcept override {
const std::pmr::memory_resource & other) const noexcept override
{
return this == &other;
}
};
Expand Down

0 comments on commit 1db7277

Please sign in to comment.