Skip to content

Commit

Permalink
[utils] Re-implement safe fail behavior into AllocatorBase
Browse files Browse the repository at this point in the history
When pulling from upstream develop, AllocatorBase has been moved to
utils/allocator.hpp. This commit simply re-introduces safe fail behavior
into AllocatorBase.construct and AllocatorBase.destroy that was
previously added by Matthew Arnold (see 3ed0768 for more details).
  • Loading branch information
manoliptram committed May 9, 2023
1 parent 5784b73 commit 1a1a888
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/modm/utils/allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class AllocatorBase
static inline void
construct(T* p, const T& value)
{
if (p == nullptr) return;
// placement new
::new((void *) p) T(value);
}
Expand All @@ -57,6 +58,7 @@ class AllocatorBase
static inline void
destroy(T* p)
{
if (p == nullptr) return;
p->~T();
}

Expand Down

0 comments on commit 1a1a888

Please sign in to comment.