\internal Allocates \a size bytes. The returned pointer is guaranteed to have 16 or 32 bytes alignment depending on the requirements. * On allocation error, the returned pointer is null, and std::bad_alloc is thrown. */
| 151 | * On allocation error, the returned pointer is null, and std::bad_alloc is thrown. |
| 152 | */ |
| 153 | EIGEN_DEVICE_FUNC inline void* aligned_malloc(std::size_t size) |
| 154 | { |
| 155 | check_that_malloc_is_allowed(); |
| 156 | |
| 157 | void *result; |
| 158 | #if (EIGEN_DEFAULT_ALIGN_BYTES==0) || EIGEN_MALLOC_ALREADY_ALIGNED |
| 159 | result = std::malloc(size); |
| 160 | #if EIGEN_DEFAULT_ALIGN_BYTES==16 |
| 161 | eigen_assert((size<16 || (std::size_t(result)%16)==0) && "System's malloc returned an unaligned pointer. Compile with EIGEN_MALLOC_ALREADY_ALIGNED=0 to fallback to handmade alignd memory allocator."); |
| 162 | #endif |
| 163 | #else |
| 164 | result = handmade_aligned_malloc(size); |
| 165 | #endif |
| 166 | |
| 167 | if(!result && size) |
| 168 | throw_std_bad_alloc(); |
| 169 | |
| 170 | return result; |
| 171 | } |
| 172 | |
| 173 | /** \internal Frees memory allocated with aligned_malloc. */ |
| 174 | EIGEN_DEVICE_FUNC inline void aligned_free(void *ptr) |
no test coverage detected