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