code: private void expand(int roomNeeded)
      {
          // First, let's move current segment to segment list:
          if (mSegments == null) {
              mSegments = new ArrayList<char[]>();
          }
          char[] curr = mCurrentSegment;
          mHasSegments = true;
          mSegments.add(curr);
          int oldLen = curr.length;
          mSegmentSize += oldLen;
          int newSize = Math.max(roomNeeded, calcNewSize(oldLen));
          curr = new char[newSize];
          mCurrentSize = 0;
          mCurrentSegment = curr;
      }
docs: Method called when current segment is full, to allocate new
  segment.
  
  @param roomNeeded Number of characters that the resulting
  new buffer must have