Skip to content

Commit 7a46ca0

Browse files
committed
core: fix aligned_malloc
1 parent c2da564 commit 7a46ca0

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

include/eigenpy/alignment.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <boost/python/converter/arg_from_python.hpp>
1010
#include <boost/python/converter/rvalue_from_python_data.hpp>
1111
#include <boost/type_traits/aligned_storage.hpp>
12+
#include <eigenpy/utils/is-aligned.hpp>
1213

1314
namespace eigenpy {
1415

@@ -33,6 +34,7 @@ inline void *aligned_malloc(
3334
std::size_t size, std::size_t alignment = EIGENPY_DEFAULT_ALIGN_BYTES) {
3435
void *original = std::malloc(size + alignment);
3536
if (original == 0) return 0;
37+
if (is_aligned(original, alignment)) return original;
3638
void *aligned =
3739
reinterpret_cast<void *>((reinterpret_cast<std::size_t>(original) &
3840
~(std::size_t(alignment - 1))) +

0 commit comments

Comments
 (0)