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