diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2017-12-11 15:07:18 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2017-12-11 15:07:18 +0100 |
commit | 1087a7f4ad8bb1bc9bf4472bf2734b0e4929e7d1 (patch) | |
tree | 639e403dfe0bce5c2714274d19f540223e072def /src/Buffer.cpp | |
parent | 1ed50fe16d749ac3a841650c4054d137b9cf7a10 (diff) | |
download | dabmod-1087a7f4ad8bb1bc9bf4472bf2734b0e4929e7d1.tar.gz dabmod-1087a7f4ad8bb1bc9bf4472bf2734b0e4929e7d1.tar.bz2 dabmod-1087a7f4ad8bb1bc9bf4472bf2734b0e4929e7d1.zip |
Remove references to malloc.h and use posix_memalign
Diffstat (limited to 'src/Buffer.cpp')
-rw-r--r-- | src/Buffer.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 8631c42..6b14561 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -30,13 +30,6 @@ #include <stdlib.h> #include <string.h> -#include <malloc.h> -#if HAVE_DECL__MM_MALLOC -# include <mm_malloc.h> -#else -# define memalign(a, b) malloc(b) -#endif - Buffer::Buffer(size_t len, const void *data) @@ -92,7 +85,10 @@ void Buffer::setLength(size_t len) void *tmp = data; /* Align to 32-byte boundary for AVX. */ - data = memalign(32, len); + const int ret = posix_memalign(&data, 32, len); + if (ret != 0) { + throw std::runtime_error("memory allocation failed: " + std::to_string(ret)); + } if (tmp != NULL) { memcpy(data, tmp, this->len); |