Bubblesort manually translated from RPerl into C++ now works, although it may still be leaking a little memory