GCC Code Coverage Report


Directory: codebase/
File: codebase/library/include/public/lib.SmartPointerDeleter.hpp
Date: 2023-03-16 04:37:09
Exec Total Coverage
Lines: 6 6 100.0%
Functions: 5 5 100.0%
Branches: 3 4 75.0%

Line Branch Exec Source
1 /**
2 * @file lib.SmartPointerDeleter.hpp
3 * @author Sergey Baigudin, sergey@baigudin.software
4 * @copyright 2022, Sergey Baigudin, Baigudin Software
5 */
6 #ifndef LIB_SMARTPOINTERDELETER_HPP_
7 #define LIB_SMARTPOINTERDELETER_HPP_
8
9 #include "lib.Types.hpp"
10
11 namespace eoos
12 {
13 namespace lib
14 {
15
16 #ifdef EOOS_ENABLE_DYNAMIC_HEAP_MEMORY
17
18 /**
19 * @class SmartPointerDeleter<T>
20 * @brief Deleter of smart pointers allocated with new operator.
21 *
22 * @tparam T Data type of an owning object.
23 */
24 template <typename T>
25 class SmartPointerDeleter
26 {
27
28 public:
29
30 /**
31 * @brief Frees an allocated object.
32 *
33 * @param ptr Address of allocated the owning object.
34 */
35 275 static void free(T* const ptr)
36 {
37
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 136 times.
275 delete ptr;
38 275 }
39 };
40
41 /**
42 * @class SmartPointerDeleterArray<T>
43 * @brief Deleter of smart pointers allocated with new [] operator.
44 *
45 * @tparam T Data type of an owning object.
46 */
47 template <typename T>
48 class SmartPointerDeleterArray
49 {
50
51 public:
52
53 /**
54 * @brief Frees an allocated array of objects.
55 *
56 * @param ptr Address of allocated the owning objects.
57 */
58 2 static void free(T* const ptr)
59 {
60
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 delete [] ptr;
61 2 }
62 };
63
64 #endif // EOOS_ENABLE_DYNAMIC_HEAP_MEMORY
65
66 } // namespace lib
67 } // namespace eoos
68 #endif // LIB_SMARTPOINTERDELETER_HPP_
69