F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
MallocAllocator.cpp
Go to the documentation of this file.
1
14#include <cstdlib>
15
16namespace Fw {
17
19
21
22void* MallocAllocator::allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYPE& size, bool& recoverable) {
23 // don't use identifier
24 // heap memory is never recoverable
25 recoverable = false;
26 void* mem = ::malloc(size);
27 if (nullptr == mem) {
28 size = 0; // set to zero if can't get memory
29 }
30 return mem;
31}
32
33void MallocAllocator::deallocate(const NATIVE_UINT_TYPE identifier, void* ptr) {
34 ::free(ptr);
35}
36
37} /* namespace Fw */
PlatformUIntType NATIVE_UINT_TYPE
Definition BasicTypes.h:56
A MemAllocator implementation class that uses malloc.
void * allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYPE &size, bool &recoverable)
Allocate memory.
void deallocate(const NATIVE_UINT_TYPE identifier, void *ptr)
Deallocate memory.