mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd::buffer: Use c++17 switch here; addl assertions.
This commit is contained in:
parent
672dc48d1d
commit
286aee740b
1 changed files with 8 additions and 2 deletions
|
@ -110,9 +110,12 @@ ircd::buffer::aligned_alloc(const size_t &align,
|
|||
align?: align_default
|
||||
};
|
||||
|
||||
int errc;
|
||||
assert(alignment % 2UL == 0);
|
||||
assert(alignment % sizeof(void *) == 0);
|
||||
assert(size % alignment == 0);
|
||||
|
||||
void *ret;
|
||||
switch((errc = ::posix_memalign(&ret, alignment, size)))
|
||||
switch(int errc(::posix_memalign(&ret, alignment, size)); errc)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
|
@ -127,6 +130,9 @@ ircd::buffer::aligned_alloc(const size_t &align,
|
|||
};
|
||||
}
|
||||
|
||||
assert(ret != nullptr);
|
||||
assert(uintptr_t(ret) % alignment == 0);
|
||||
|
||||
return std::unique_ptr<char, decltype(&std::free)>
|
||||
{
|
||||
reinterpret_cast<char *>(ret), &std::free
|
||||
|
|
Loading…
Reference in a new issue