Fix memory leaks
This commit is contained in:
parent
4d3dfce93f
commit
692393285d
5 changed files with 24 additions and 23 deletions
|
@ -102,12 +102,16 @@ System.print("You have %(cale.appointment_count()) appointment(s)")
|
|||
char* load_module_fn(wren::VM* vm, std::string_view module_name) {
|
||||
if (module_name == "calendar") {
|
||||
constexpr const std::size_t buff_sz = sizeof(g_calendar_src);
|
||||
char* const buff = static_cast<char*>(MyConf::reallocate_fn(nullptr, buff_sz));
|
||||
char* const buff = new char[buff_sz];
|
||||
std::copy(g_calendar_src, g_calendar_src + buff_sz / sizeof(g_calendar_src[0]), buff);
|
||||
return buff;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void load_module_complete_fn(wren::VM*, std::string_view, char* buffer) {
|
||||
delete[] buffer;
|
||||
}
|
||||
};
|
||||
} //unnamed namespace
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue