malloc apparently has troubles allocating memory for std::function objects, switching to new