Fix memory leaks
This commit is contained in:
parent
4d3dfce93f
commit
692393285d
5 changed files with 24 additions and 23 deletions
|
@ -81,9 +81,10 @@ System.print("vec3 modified by scripting: <%(vec3.x), %(vec3.y), %(vec3.z)>")
|
|||
public:
|
||||
char* load_module_fn(wren::VM* vm, std::string_view module_name) {
|
||||
if (module_name == "math_vector") {
|
||||
constexpr const std::size_t buff_sz = g_math_vector_src.size();
|
||||
constexpr const std::size_t buff_sz = g_math_vector_src.size() + 1;
|
||||
char* const buff = static_cast<char*>(MyConf::reallocate_fn(nullptr, buff_sz));
|
||||
std::copy(g_math_vector_src.cbegin(), g_math_vector_src.cend(), buff);
|
||||
buff[buff_sz - 1] = '\0';
|
||||
return buff;
|
||||
}
|
||||
return nullptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue