Skip to content
Snippets Groups Projects
Verified Commit c2da564f authored by Justin Carpentier's avatar Justin Carpentier
Browse files

core: add aligned_malloc

parent 4bf12f96
No related branches found
No related tags found
No related merge requests found
...@@ -29,6 +29,18 @@ struct aligned_instance { ...@@ -29,6 +29,18 @@ struct aligned_instance {
typename aligned_storage<sizeof(Data)>::type storage; typename aligned_storage<sizeof(Data)>::type storage;
}; };
inline void *aligned_malloc(
std::size_t size, std::size_t alignment = EIGENPY_DEFAULT_ALIGN_BYTES) {
void *original = std::malloc(size + alignment);
if (original == 0) return 0;
void *aligned =
reinterpret_cast<void *>((reinterpret_cast<std::size_t>(original) &
~(std::size_t(alignment - 1))) +
alignment);
*(reinterpret_cast<void **>(aligned) - 1) = original;
return aligned;
}
} // namespace eigenpy } // namespace eigenpy
namespace boost { namespace boost {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment