GCC Code Coverage Report


Directory: ./
File: src/segment_info.cpp
Date: 2022-06-30 06:29:57
Exec Total Coverage
Lines: 15 21 71.4%
Branches: 2 4 50.0%

Line Branch Exec Source
1 // Copyright 2019 @ Max Planck Gesellschaft and New York University
2 // License BSD-3-Clause
3
4 #include "shared_memory/segment_info.hpp"
5
6 namespace shared_memory
7 {
8 // dev note : the boost api does not allow for msm to be const
9 2 SegmentInfo::SegmentInfo(boost::interprocess::managed_shared_memory &msm)
10 {
11 2 size_ = msm.get_size();
12 2 free_memory_ = msm.get_free_memory();
13 2 has_issues_ = !msm.check_sanity();
14 // -1 : there is one default object per segment.
15 // it is clearer to returns the number of objects created
16 // by users
17 2 nb_objects_ = msm.get_num_named_objects() - 1;
18 2 }
19
20 2 uint SegmentInfo::get_size() const
21 {
22 2 return size_;
23 }
24
25 2 uint SegmentInfo::get_free_memory() const
26 {
27 2 return free_memory_;
28 }
29
30 2 bool SegmentInfo::has_issues() const
31 {
32 2 return has_issues_;
33 }
34
35 2 uint SegmentInfo::nb_objects() const
36 {
37 2 return nb_objects_;
38 }
39
40 void SegmentInfo::print() const
41 {
42 std::cout << "Memory segment:"
43 << "\n"
44 << "\tsize:\t" << size_ << "\n"
45 << "\tfree:\t" << free_memory_ << "\n"
46 << "\tused:\t" << size_ - free_memory_ << "\n"
47 << "\tobjects\t" << nb_objects_ << "\n"
48 << "\thas issues:\t" << has_issues_ << std::endl;
49 }
50
51
2/4
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
✗ Branch 4 not taken.
162 } // namespace shared_memory
52