<commit_before>/*
 * Copyright (C) 2014 <NAME> <<EMAIL>>
 */

#pragma once

#if __GNUC__
// We need auto_ptr for compatibility reasons
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif

#include <uavcan/node/abstract_node.hpp>
#include <memory>
#include <set>
#include <queue>
#include "../transport/can/can.hpp"
#include <uavcan/util/method_binder.hpp>
#include <uavcan/node/subscriber.hpp>

struct TestNode : public uavcan::INode
{
    uavcan::PoolAllocator<uavcan::MemPoolBlockSize * 1024, uavcan::MemPoolBlockSize> pool;
    uavcan::Scheduler scheduler;
    uint64_t internal_failure_count;

    TestNode(uavcan::ICanDriver& can_driver, uavcan::ISystemClock& clock_driver, uavcan::NodeID self_node_id)
        : scheduler(can_driver, pool, clock_driver)
        , internal_failure_count(0)
    {
        setNodeID(self_node_id);
    }

    virtual void registerInternalFailure(const char* msg)
    {
        std::cout << "TestNode internal failure: " << msg << std::endl;
        internal_failure_count++;
    }
<commit_msg>TestNode uses heap based allocator now<commit_after>/*
 * Copyright (C) 2014 <NAME> <<EMAIL>>
 */

#pragma once

#if __GNUC__
// We need auto_ptr for compatibility reasons
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif

#include <uavcan/node/abstract_node.hpp>
#include <uavcan/helpers/heap_based_pool_allocator.hpp>
#include <memory>
#include <set>
#include <queue>
#include "../transport/can/can.hpp"
#include <uavcan/util/method_binder.hpp>
#include <uavcan/node/subscriber.hpp>

struct TestNode : public uavcan::INode
{
    /*
     * This class used to use the simple pool allocator instead:
     *  uavcan::PoolAllocator<uavcan::MemPoolBlockSize * 1024, uavcan::MemPoolBlockSize> pool;
     * It has been replaced because unlike the simple allocator, heap-based one is not tested as extensively.
     * Moreover, heap based allocator prints and error message upon destruction if some memory has not been freed.
     */
    uavcan::HeapBasedPoolAllocator<uavcan::MemPoolBlockSize> pool;
    uavcan::Scheduler scheduler;
    uint64_t internal_failure_count;

    TestNode(uavcan::ICanDriver& can_driver, uavcan::ISystemClock& clock_driver, uavcan::NodeID self_node_id) :
        pool(1024),
        scheduler(can_driver, pool, clock_driver),
        internal_failure_count(0)
    {
        setNodeID(self_node_id);
    }

    virtual void registerInternalFailure(const char* msg)
    {
        std::cout << "TestNode internal failure: " << msg << std::endl;
        internal_failure_count++;
    }

{'fraction_non_alphanumeric': 0.11145752143413874, 'fraction_numerical': 0.010132501948558068, 'mean_word_length': 4.228105906313646, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1862847', 'n_tokens_mistral': 855, 'n_tokens_neox': 828, 'n_words': 195}