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)
|
allocate (size_t count, size_t align)
|
||||||
{
|
{
|
||||||
void* ptr;
|
void* ptr;
|
||||||
posix_memalign (&ptr, align, sizeof (T) * count);
|
auto err = posix_memalign (&ptr, align, sizeof (T) * count);
|
||||||
if (!ptr)
|
if (err or !ptr)
|
||||||
throw std::bad_alloc ();
|
throw std::bad_alloc ();
|
||||||
|
|
||||||
return { reinterpret_cast<T*> (ptr), count };
|
return { reinterpret_cast<T*> (ptr), count };
|
||||||
|
Loading…
Reference in New Issue
Block a user