Use a bit mask to wrap the buffer index