BUG: Fix possibly incorrect buffer reuse in nditer reduction

When a buffer is reused, but in the previous iteration the outer
reduction iteration was not at 0 (i.e. the first dimension
being iterated, that is not part of the reduction), then it was
possible that in the next iteration the buffer was reused, since
the pointers can be the same. But the amount of data copied in
the new iteration would have been larger then what was buffered
before. To avoid this, this does two things:
  1. Disallow reusing of buffers when the iteration was not at 0,
     (unless it may already be reused, when it is safe)
  2. Shrink the buffer, so that its end always corresponds to as
     many zeros in the index as possible, so that these are
     prefered, since they are safe.

---

This hopefully fixes gh-3142. The tests still missing, though I guess I could mostly reuse an example from there. @mwiebe does this make sense? @jluttine  maybe you want to test this more. Probably needs some clearer comments...