alloc/malloc: remember to check memalign return value
This commit is contained in:
parent
aaa00bc989
commit
343b3d36ce
@ -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 };
|
||||
|
Loading…
Reference in New Issue
Block a user