private void ensureCapacity(int desiredSize) {
    if (data.length < desiredSize) {
      byte[] newData = new byte[desiredSize * 2 + 1000];
      System.arraycopy(data, 0, newData, 0, cursor);
      data = newData;
    }
  }
Reallocates the underlying array if necessary. Calls to this method should be guarded by a test
of {@link #stretchy}.

@param desiredSize {@code >= 0;} the desired minimum total size of the array
android/android_framework/dex-maker/src/main/java/com/android/dx/util/ByteArrayAnnotatedOutput.java