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

Function aligned_malloc

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

\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. */

Source from the content-addressed store, hash-verified

205 * On allocation error, the returned pointer is null, and std::bad_alloc is thrown.
206 */
207EIGEN_DEVICE_FUNC inline void* aligned_malloc(std::size_t size)
208{
209 if (size == 0) return nullptr;
210
211 void *result;
212 #if (EIGEN_DEFAULT_ALIGN_BYTES==0) || EIGEN_MALLOC_ALREADY_ALIGNED
213
214 check_that_malloc_is_allowed();
215 EIGEN_USING_STD(malloc)
216 result = malloc(size);
217
218 #if EIGEN_DEFAULT_ALIGN_BYTES==16
219 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 aligned memory allocator.");
220 #endif
221 #else
222 result = handmade_aligned_malloc(size);
223 #endif
224
225 if(!result && size)
226 throw_std_bad_alloc();
227
228 return result;
229}
230
231/** \internal Frees memory allocated with aligned_malloc. */
232EIGEN_DEVICE_FUNC inline void aligned_free(void *ptr)

Calls 3

handmade_aligned_mallocFunction · 0.85
throw_std_bad_allocFunction · 0.85

Tested by

no test coverage detected