put preallocation in its own function in Newton.c