ext/rmath3d/rmath3d.c: Fixed memory management