alloc/malloc: remember to check memalign return value

This commit is contained in:
Danny Robson 2023-07-21 14:19:39 +10:00
parent aaa00bc989
commit 343b3d36ce

View File

@ -39,8 +39,8 @@ namespace cruft::alloc {
allocate (size_t count, size_t align)
{
void* ptr;
posix_memalign (&ptr, align, sizeof (T) * count);
if (!ptr)
auto err = posix_memalign (&ptr, align, sizeof (T) * count);
if (err or !ptr)
throw std::bad_alloc ();
return { reinterpret_cast<T*> (ptr), count };