MCPcopy Create free account
hub / github.com/PX4/eigen / aligned_malloc

Function aligned_malloc

Eigen/src/Core/util/Memory.h:153–171  ·  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

151 * On allocation error, the returned pointer is null, and std::bad_alloc is thrown.
152 */
153EIGEN_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. */
174EIGEN_DEVICE_FUNC inline void aligned_free(void *ptr)

Callers 9

allocateMethod · 0.85
check_aligned_mallocFunction · 0.85
allocateMethod · 0.85
allocateMethod · 0.85
allocateMethod · 0.85
ContextMethod · 0.85
MaxSizeVectorMethod · 0.85

Calls 3

handmade_aligned_mallocFunction · 0.85
throw_std_bad_allocFunction · 0.85

Tested by

no test coverage detected