I created a version that eliminates malloc replacing allocations with std::vector, would you like a pull request for it?