/** * \author T. Canham * \brief Implementation of malloc based allocator * * \copyright * Copyright 2009-2016, by the California Institute of Technology. * ALL RIGHTS RESERVED. United States Government Sponsorship * acknowledged. */ #include #include #include namespace Fw { void* MallocAllocator::allocate(const FwEnumStoreType identifier, FwSizeType& size, bool& recoverable, FwSizeType alignment) { // don't use identifier // heap memory is never recoverable recoverable = false; FW_ASSERT(size < std::numeric_limits::max()); void* mem = ::malloc(static_cast(size)); if (nullptr == mem) { size = 0; // set to zero if can't get memory } return mem; } void MallocAllocator::deallocate(const FwEnumStoreType identifier, void* ptr) { ::free(ptr); } } /* namespace Fw */