Don't allocate more buffer memory than we need.