ATLAS Offline Software
DataModelTestDataRead/src/AllocTestAuxContainer_v1.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
12 #undef NDEBUG
15 
16 
17 namespace {
18 
19 
26 class TestMemResource
27  : public std::pmr::memory_resource
28 {
29 public:
30  constexpr static size_t MAGIC = 0xdeadbeefcafefeed;
31 
32  virtual void* do_allocate (size_t bytes, std::size_t /*alignment*/) override
33  {
34  size_t* p = reinterpret_cast<size_t*>(malloc (bytes + 2*sizeof(size_t)));
35  p[0] = bytes;
36  p[1] = MAGIC;
37  return p + 2;
38  }
39 
40  virtual void do_deallocate (void* p, [[maybe_unused]] std::size_t bytes, std::size_t /*alignment*/) override
41  {
42  size_t* pp = reinterpret_cast<size_t*>(p);
43  pp -= 2;
44  assert (pp[0] == bytes);
45  assert (pp[1] == MAGIC);
46  free (pp);
47  }
48 
49  virtual bool do_is_equal (const std::pmr::memory_resource& other) const noexcept override
50  {
51  return dynamic_cast<const TestMemResource*> (&other) != nullptr;
52  }
53 };
54 
55 
56 // No state, so thread-safe.
57 static TestMemResource memRes ATLAS_THREAD_SAFE;
58 
59 
60 }
61 
62 
63 namespace DMTest {
64 
65 
67  : xAOD::AuxContainerBase(&memRes)
68 {
69 }
70 
71 
73  : xAOD::AuxContainerBase(),
74  atInt1 (r)
75 {
76 }
77 
78 
79 } // namespace DMTest
beamspotman.r
def r
Definition: beamspotman.py:676
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
TrigInDetValidation_Base.malloc
malloc
Definition: TrigInDetValidation_Base.py:132
AllocTestAuxContainer_v1.h
Testing an xAOD object with a non-standard memory allocator.
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
checker_macros.h
Define macros for attributes used to control the static checker.
DMTest::AllocTestAuxContainer_v1::AllocTestAuxContainer_v1
AllocTestAuxContainer_v1()
Definition: DataModelTestDataRead/src/AllocTestAuxContainer_v1.cxx:66
DMTest
Definition: B.h:23