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

Function handmade_aligned_malloc

Eigen/src/Core/util/Memory.h:86–93  ·  view source on GitHub ↗

\internal Like malloc, but the returned pointer is guaranteed to be 16-byte aligned. * Fast, but wastes 16 additional bytes of memory. Does not throw any exception. */

Source from the content-addressed store, hash-verified

84 * Fast, but wastes 16 additional bytes of memory. Does not throw any exception.
85 */
86inline void* handmade_aligned_malloc(std::size_t size)
87{
88 void *original = std::malloc(size+EIGEN_DEFAULT_ALIGN_BYTES);
89 if (original == 0) return 0;
90 void *aligned = reinterpret_cast<void*>((reinterpret_cast<std::size_t>(original) & ~(std::size_t(EIGEN_DEFAULT_ALIGN_BYTES-1))) + EIGEN_DEFAULT_ALIGN_BYTES);
91 *(reinterpret_cast<void**>(aligned) - 1) = original;
92 return aligned;
93}
94
95/** \internal Frees memory allocated with handmade_aligned_malloc */
96inline void handmade_aligned_free(void *ptr)

Callers 3

handmade_aligned_reallocFunction · 0.85
aligned_mallocFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected