ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
DataModelTest
DataModelTestDataRead
src
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
13
#include "
DataModelTestDataRead/versions/AllocTestAuxContainer_v1.h
"
14
#include "
CxxUtils/checker_macros.h
"
15
#include "
CxxUtils/xmalloc.h
"
16
17
18
namespace
{
19
20
27
class
TestMemResource
28
:
public
std::pmr::memory_resource
29
{
30
public
:
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.
58
static
TestMemResource memRes
ATLAS_THREAD_SAFE
;
59
60
61
}
62
63
64
namespace
DMTest
{
65
66
67
AllocTestAuxContainer_v1::AllocTestAuxContainer_v1
()
68
:
xAOD
::
AuxContainerBase
(&memRes)
69
{
70
}
71
72
73
AllocTestAuxContainer_v1::AllocTestAuxContainer_v1
(std::pmr::memory_resource*
r
)
74
:
xAOD
::
AuxContainerBase
(),
75
atInt1 (
r
)
76
{
77
}
78
79
80
}
// namespace DMTest
AllocTestAuxContainer_v1.h
Testing an xAOD object with a non-standard memory allocator.
checker_macros.h
Define macros for attributes used to control the static checker.
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition
checker_macros.h:211
DMTest::AllocTestAuxContainer_v1::AllocTestAuxContainer_v1
AllocTestAuxContainer_v1()
Definition
DataModelTestDataRead/src/AllocTestAuxContainer_v1.cxx:67
xAOD::AuxContainerBase::AuxContainerBase
AuxContainerBase(bool allowDynamicVars=true)
Default constructor.
Definition
AuxContainerBase.cxx:33
r
int r
Definition
globals.cxx:22
CxxUtils::xmalloc
void * xmalloc(size_t size)
Trapping version of malloc.
Definition
xmalloc.cxx:31
DMTest
Definition
B.h:23
InDetDD::other
@ other
Definition
InDetDD_Defs.h:16
SG::free
void free(pointer p)
Free an element.
python.utils.AtlRunQueryDQUtils.p
p
Definition
AtlRunQueryDQUtils.py:209
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition
ICaloAffectedTool.h:24
xmalloc.h
Trapping version of malloc.
Generated on
for ATLAS Offline Software by
1.17.0