* \internal * \brief Reallocates an aligned block of memory. * \throws std::bad_alloc on allocation failure */
| 241 | * \throws std::bad_alloc on allocation failure |
| 242 | */ |
| 243 | EIGEN_DEVICE_FUNC inline void* aligned_realloc(void* ptr, std::size_t new_size, std::size_t old_size) { |
| 244 | if (ptr == nullptr) return aligned_malloc(new_size); |
| 245 | if (old_size == new_size) return ptr; |
| 246 | if (new_size == 0) { |
| 247 | aligned_free(ptr); |
| 248 | return nullptr; |
| 249 | } |
| 250 | |
| 251 | void* result; |
| 252 | #if (EIGEN_DEFAULT_ALIGN_BYTES == 0) || EIGEN_MALLOC_ALREADY_ALIGNED |
| 253 | EIGEN_UNUSED_VARIABLE(old_size) |
| 254 | |
| 255 | check_that_malloc_is_allowed(); |
| 256 | EIGEN_USING_STD(realloc) |
| 257 | result = realloc(ptr, new_size); |
| 258 | #else |
| 259 | result = handmade_aligned_realloc(ptr, new_size, old_size); |
| 260 | #endif |
| 261 | |
| 262 | if (!result && new_size) throw_std_bad_alloc(); |
| 263 | |
| 264 | return result; |
| 265 | } |
| 266 | |
| 267 | /***************************************************************************** |
| 268 | *** Implementation of conditionally aligned functions *** |
no test coverage detected