Add malloc cast to fix MSVC compile error