aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-08-03 14:59:01 -0700
committerChris Robinson <[email protected]>2019-08-03 14:59:01 -0700
commit559d1666b8b029412ec9fe1bf2744dc9a4650583 (patch)
treeae17e60f64d6a799998db40576e18c9ca995f028 /common
parent13222d719d7a38b46cf0b02771acffea5d569d46 (diff)
Add a Create method to FlexArray for "raw" arrays
Diffstat (limited to 'common')
-rw-r--r--common/almalloc.h5
1 files changed, 5 insertions, 0 deletions
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<FlexArray> Create(index_type count)
+ {
+ void *ptr{al_calloc(alignof(FlexArray), Sizeof(count))};
+ return std::unique_ptr<FlexArray>{new (ptr) FlexArray{count}};
+ }
static constexpr index_type Sizeof(index_type count, index_type base=0u) noexcept
{
return base +