Various utilities for handling arrays and memory.
Returns a new array with at most length newLength.
Swaps the variables a and b.