GCC Code Coverage Report


Directory: ./
File: Fw/Types/MallocAllocator.cpp
Date: 2026-09-03 22:12:29
Exec Total Coverage
Lines: 9 10 90.0%
Functions: 2 2 100.0%
Branches: 1 2 50.0%

Line Branch Exec Source
1 /**
2 * \author T. Canham
3 * \brief Implementation of malloc based allocator
4 *
5 * \copyright
6 * Copyright 2009-2016, by the California Institute of Technology.
7 * ALL RIGHTS RESERVED. United States Government Sponsorship
8 * acknowledged.
9 */
10 #include <Fw/Types/Assert.hpp>
11 #include <Fw/Types/MallocAllocator.hpp>
12 #include <cstdlib>
13
14 namespace Fw {
15
16 119 void* MallocAllocator::allocate(const FwEnumStoreType identifier,
17 FwSizeType& size,
18 bool& recoverable,
19 FwSizeType alignment) {
20 // don't use identifier
21 // heap memory is never recoverable
22 119 recoverable = false;
23 119 FW_ASSERT(size < std::numeric_limits<size_t>::max());
24 119 void* mem = ::malloc(static_cast<size_t>(size));
25
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if (nullptr == mem) {
26 size = 0; // set to zero if can't get memory
27 }
28 119 return mem;
29 }
30
31 119 void MallocAllocator::deallocate(const FwEnumStoreType identifier, void* ptr) {
32 119 ::free(ptr);
33 119 }
34 } /* namespace Fw */
35