From 559d1666b8b029412ec9fe1bf2744dc9a4650583 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 3 Aug 2019 14:59:01 -0700 Subject: Add a Create method to FlexArray for "raw" arrays --- common/almalloc.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'common') diff --git a/common/almalloc.h b/common/almalloc.h index 3fc979c9..ca92316a 100644 --- a/common/almalloc.h +++ b/common/almalloc.h @@ -223,6 +223,11 @@ struct FlexArray { const index_type mSize; alignas(alignment) element_type mArray[0]; + static std::unique_ptr Create(index_type count) + { + void *ptr{al_calloc(alignof(FlexArray), Sizeof(count))}; + return std::unique_ptr{new (ptr) FlexArray{count}}; + } static constexpr index_type Sizeof(index_type count, index_type base=0u) noexcept { return base + -- cgit v1.2.3