F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Fw::MallocAllocator Class Reference

malloc based memory allocator More...

#include <Fw/Types/MallocAllocator.hpp>

Inheritance diagram for Fw::MallocAllocator:
Fw::MemAllocator

Public Member Functions

 MallocAllocator ()=default
 
virtual ~MallocAllocator ()=default
 
void * allocate (const FwEnumStoreType identifier, FwSizeType &size, bool &recoverable, FwSizeType alignment=alignof(std::max_align_t)) override
 
void deallocate (const FwEnumStoreType identifier, void *ptr) override
 
- Public Member Functions inherited from Fw::MemAllocator
void * allocate (const FwEnumStoreType identifier, FwSizeType &size, FwSizeType alignment=alignof(std::max_align_t))
 
void * checkedAllocate (const FwEnumStoreType identifier, FwSizeType &size, bool &recoverable, FwSizeType alignment=alignof(std::max_align_t))
 
void * checkedAllocate (const FwEnumStoreType identifier, FwSizeType &size, FwSizeType alignment=alignof(std::max_align_t))
 

Additional Inherited Members

- Protected Member Functions inherited from Fw::MemAllocator
 MemAllocator ()
 
virtual ~MemAllocator ()
 

Detailed Description

malloc based memory allocator

This class implements a memory allocator that uses malloc/free to allocate memory and deallocate memory. malloc() guarantees alignment for any type and thus does this allocator. It will not respect smaller alignments.

Since this directs to heap space, the identifier is unused and memory is never recoverable.

Definition at line 26 of file MallocAllocator.hpp.

Constructor & Destructor Documentation

◆ MallocAllocator()

Fw::MallocAllocator::MallocAllocator ( )
default

◆ ~MallocAllocator()

virtual Fw::MallocAllocator::~MallocAllocator ( )
virtualdefault

Member Function Documentation

◆ allocate()

void * Fw::MallocAllocator::allocate ( const FwEnumStoreType  identifier,
FwSizeType size,
bool &  recoverable,
FwSizeType  alignment = alignof(std::max_align_t) 
)
overridevirtual

Allocate memory

Allocate memory using malloc(). The identifier is unused and memory is never recoverable. malloc() guarantees alignment for any type and so does this allocator. It will not respect smaller alignments.

Parameters
identifierthe memory segment identifier (not used)
sizethe requested size (not changed)
recoverable- flag to indicate the memory could be recoverable (always set to false)
alignment- alignment requirement for the allocation. Default: maximum alignment defined by C++.
Returns
the pointer to memory. Zero if unable to allocate.

Implements Fw::MemAllocator.

Definition at line 16 of file MallocAllocator.cpp.

◆ deallocate()

void Fw::MallocAllocator::deallocate ( const FwEnumStoreType  identifier,
void *  ptr 
)
overridevirtual

Deallocate memory

Deallocate memory previously allocated by allocate() using free(). The identifier is unused but should still match the original call.

Parameters
identifierthe memory segment identifier (not used)
ptrthe pointer to memory returned by allocate()

Implements Fw::MemAllocator.

Definition at line 31 of file MallocAllocator.cpp.


The documentation for this class was generated from the following files: