add #include <cstdlib> for memcpy