Skip to content

Commit 364b7b2

Browse files
committed
Fix a double-free error by removing a static object.
1 parent d4a5db8 commit 364b7b2

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

src/axom/core/execution/execution_space.hpp

+10-18
Original file line numberDiff line numberDiff line change
@@ -127,30 +127,22 @@ namespace axom
127127
{
128128

129129
/// \brief Return default allocator id for a runtime policy.
130-
static const std::map<axom::runtime_policy::Policy, int> s_policyToDefaultAllocatorID {
131-
{axom::runtime_policy::Policy::seq,
132-
axom::execution_space<axom::SEQ_EXEC>::allocatorID()}
130+
inline int policyToDefaultAllocatorID(axom::runtime_policy::Policy policy)
131+
{
132+
return
133133
#if defined(AXOM_RUNTIME_POLICY_USE_OPENMP)
134-
,
135-
{axom::runtime_policy::Policy::omp,
136-
axom::execution_space<axom::OMP_EXEC>::allocatorID()}
134+
policy == axom::runtime_policy::Policy::omp ?
135+
axom::execution_space<axom::OMP_EXEC>::allocatorID() :
137136
#endif
138137
#if defined(AXOM_RUNTIME_POLICY_USE_CUDA)
139-
,
140-
{axom::runtime_policy::Policy::cuda,
141-
axom::execution_space<axom::CUDA_EXEC<256>>::allocatorID()}
138+
policy == axom::runtime_policy::Policy::cuda ?
139+
axom::execution_space<axom::CUDA_EXEC<256>>::allocatorID() :
142140
#endif
143141
#if defined(AXOM_RUNTIME_POLICY_USE_HIP)
144-
,
145-
{axom::runtime_policy::Policy::hip,
146-
axom::execution_space<axom::HIP_EXEC<256>>::allocatorID()}
142+
policy == axom::runtime_policy::Policy::hip ?
143+
axom::execution_space<axom::HIP_EXEC<256>>::allocatorID() :
147144
#endif
148-
};
149-
150-
/// \brief Return default allocator id for a runtime policy.
151-
inline int policyToDefaultAllocatorID(axom::runtime_policy::Policy policy)
152-
{
153-
return s_policyToDefaultAllocatorID.find(policy)->second;
145+
axom::execution_space<axom::SEQ_EXEC>::allocatorID() ;
154146
}
155147

156148
} // namespace axom

0 commit comments

Comments
 (0)