WeaselGames / godot_luaAPI

Godot LuaAPI
https://luaapi.weaselgames.info
Other
361 stars 27 forks source link

Use memmove instead of memcpy #129

Closed Trey2k closed 1 year ago

Trey2k commented 1 year ago

This PR fixes some pretty bad memory leaks. Somewhere along the line a bad assumption was made that memcpy had to be used instead of just storing the value. While just storing the value does work for module builds, because of how GDExtension works it cant really handle a null Variant. This is because all variants even null ones point to a Variant in the engine its self. Thus when we assign a real value to a null variant it causes a memory exception. For this reason memmove was used instead. As a safe way to transfer the value to lua. The ref count is also incremented for RefCounted's when passed to lua. And de incremented in the lua gc.

The configure_gc method has also been added. It is a direct exposure of lua_gc from the C API.