ATLAS Offline Software
Loading...
Searching...
No Matches
DataModelTestDataRead/src/AllocTestAuxContainer_v1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
10
11
12#undef NDEBUG
15#include "CxxUtils/xmalloc.h"
16
17
18namespace {
19
20
27class TestMemResource
28 : public std::pmr::memory_resource
29{
30public:
31 constexpr static size_t MAGIC = 0xdeadbeefcafefeed;
32
33 virtual void* do_allocate (size_t bytes, std::size_t /*alignment*/) override
34 {
35 size_t* p = reinterpret_cast<size_t*>(CxxUtils::xmalloc (bytes + 2*sizeof(size_t)));
36 p[0] = bytes;
37 p[1] = MAGIC;
38 return p + 2;
39 }
40
41 virtual void do_deallocate (void* p, [[maybe_unused]] std::size_t bytes, std::size_t /*alignment*/) override
42 {
43 size_t* pp = reinterpret_cast<size_t*>(p);
44 pp -= 2;
45 assert (pp[0] == bytes);
46 assert (pp[1] == MAGIC);
47 free (pp);
48 }
49
50 virtual bool do_is_equal (const std::pmr::memory_resource& other) const noexcept override
51 {
52 return dynamic_cast<const TestMemResource*> (&other) != nullptr;
53 }
54};
55
56
57// No state, so thread-safe.
58static TestMemResource memRes ATLAS_THREAD_SAFE;
59
60
61}
62
63
64namespace DMTest {
65
66
71
72
75 atInt1 (r)
76{
77}
78
79
80} // namespace DMTest
Testing an xAOD object with a non-standard memory allocator.
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
AuxContainerBase(bool allowDynamicVars=true)
Default constructor.
int r
Definition globals.cxx:22
void * xmalloc(size_t size)
Trapping version of malloc.
Definition xmalloc.cxx:31
Definition B.h:23
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Trapping version of malloc.