MCPcopy Create free account
hub / github.com/TinyMPC/TinyMPC / aligned_realloc

Function aligned_realloc

include/Eigen/Eigen/src/Core/util/Memory.h:251–272  ·  view source on GitHub ↗

* \internal * \brief Reallocates an aligned block of memory. * \throws std::bad_alloc on allocation failure */

Source from the content-addressed store, hash-verified

249 * \throws std::bad_alloc on allocation failure
250 */
251EIGEN_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 ***

Callers 1

Calls 5

aligned_mallocFunction · 0.85
aligned_freeFunction · 0.85
handmade_aligned_reallocFunction · 0.85
throw_std_bad_allocFunction · 0.85

Tested by

no test coverage detected