It's important to match g_malloc() with g_free() and plain malloc() with free()
See https://developer.gnome.org/glib/2.39/glib-Memory-Allocation.html