Skip to content

Commit ef7a270

Browse files
committed
[utils] Re-implement safe fail behavior into AllocatorBase
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).
1 parent 4d5d195 commit ef7a270

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/modm/utils/allocator.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class AllocatorBase
4242
static inline void
4343
construct(T* p, const T& value)
4444
{
45+
if (p == nullptr) return;
4546
// placement new
4647
::new((void *) p) T(value);
4748
}
@@ -57,6 +58,7 @@ class AllocatorBase
5758
static inline void
5859
destroy(T* p)
5960
{
61+
if (p == nullptr) return;
6062
p->~T();
6163
}
6264

0 commit comments

Comments
 (0)