// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once #include #include #include template struct NonCachedMemAllocator { using value_type = T; T *allocate(std::size_t num); void deallocate(T *ptr, std::size_t num); NonCachedMemAllocator() = default; NonCachedMemAllocator(const NonCachedMemAllocator &) = default; NonCachedMemAllocator(NonCachedMemAllocator &&) = default; NonCachedMemAllocator &operator=(const NonCachedMemAllocator &) = default; NonCachedMemAllocator &operator=(NonCachedMemAllocator &&) = default; }; template T *NonCachedMemAllocator::allocate(std::size_t num) { T *ptr = reinterpret_cast(pvPortMalloc(sizeof(T) * num)); return ptr; } template void NonCachedMemAllocator::deallocate(T *ptr, std::size_t) { assert(ptr != nullptr); vPortFree(ptr); }