Request a new current chunk.

@param requestedSize
The minimal size of the new buffer.
@return The new or recycled buffer.
975444
private byte[] requestChunk(int requestedSize)
	{
		mPosInChunk = 0;
		if (mCurrentChunkIndex++ < mChunkList.size() - 1)
		{
			// there is one more unused buffer in the list, return it
			return mCurrentChunk = mChunkList.get(mCurrentChunkIndex);
		}

		mChunkList.add(mCurrentChunk = new byte[Math.max(requestedSize, mMinChunkSize)]);
		return mCurrentChunk;
	}
1341731
public void setRequestedBytes(int newRequestedBytes)
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "setRequestedBytes", newRequestedBytes);
      requestedBytes = newRequestedBytes;
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "setRequestedBytes");
   }
625148
private void newBuffer(int offset) {
    if (maxBufferSize >= 0) {
      buffer = new int[maxBufferSize];
      isByte = new boolean[maxBufferSize];
      bufferOffset = offset;
      currentBufferSize = 0;
    }
  }
809958
public Uploader startUploadFileChunked(int chunkSize, String targetPath, DbxWriteMode writeMode, long numBytes)
    {
        DbxPathV1.checkArg("targetPath", targetPath);
        if (writeMode == null) throw new IllegalArgumentException("'writeMode' can't be null");

        return new ChunkedUploader(targetPath, writeMode, numBytes, new ChunkedUploadOutputStream(chunkSize));
    }
47909
protected final void resize(int requiredSize) {
    // Double until 64, then increase by 50% each time.
    int newCapacity = ((queue.length < 64) ? ((queue.length + 1) << 1) : ((queue.length >> 1) + queue.length));
    // overflow?
    if(newCapacity < 0) {
      throw new OutOfMemoryError();
    }
    if(requiredSize > newCapacity) {
      newCapacity = requiredSize;
    }
    queue = Arrays.copyOf(queue, newCapacity);
  }
281688
protected byte[] getBuffer(int size) {
    byte[] buffer;
    if (size > SERIALIZER_BUFFER_SIZE) {
      buffer = new byte[size];
    } else {
      buffer = serializerBuffers.get();
      serializerBuffers.remove();
    }
    return buffer;
  }
1337203
public Blob createNewBlob(int blockSize) throws PersistException {
        StoredLob lob = mLobStorage.prepare();
        lob.setLocator(mLocatorSequence.nextLongValue());
        lob.setBlockSize(blockSize);
        lob.setLength(0);
        lob.insert();
        return new BlobImpl(lob.getLocator());
    }
93814
static int getRequiredItemCapacity(final int k, final long newN) {
    final int numLevelsNeeded = Util.computeNumLevelsNeeded(k, newN);
    if (numLevelsNeeded == 0) {
      // don't need any levels yet, and might have small base buffer; this can happen during a merge
      return 2 * k;
    }
    // from here on we need a full-size base buffer and at least one level
    assert newN >= (2L * k);
    assert numLevelsNeeded > 0;
    final int spaceNeeded = (2 + numLevelsNeeded) * k;
    return spaceNeeded;
  }
909291
private int getChunkSize()
        throws IOException
    {
        if (_chunkSize<0)
            return -1;
        
        _trailer=null;
        _chunkSize=-1;
        
        // Get next non blank line
        org.browsermob.proxy.jetty.util.LineInput.LineBuffer line_buffer
            =_in.readLineBuffer();
        while(line_buffer!=null && line_buffer.size==0)
            line_buffer=_in.readLineBuffer();
        
        // Handle early EOF or error in format
        if (line_buffer==null)
            throw new IOException("Unexpected EOF");
        
        String line= new String(line_buffer.buffer,0,line_buffer.size);
        
        
        // Get chunksize
        int i=line.indexOf(';');
        if (i>0)
            line=line.substring(0,i).trim();
        try
        {
            _chunkSize = Integer.parseInt(line,16);
        }
        catch (NumberFormatException e)
        {
            _chunkSize=-1;
            log.warn("Bad Chunk:"+line);
            log.debug(LogSupport.EXCEPTION,e);
            throw new IOException("Bad chunk size");
        }
                 
        // check for EOF
        if (_chunkSize==0)
        {
            _chunkSize=-1;
            // Look for trailers
            _trailer = new HttpFields();
            _trailer.read(_in);
        }
        
        return _chunkSize;
    }
35427
public Request makeRequest(HttpMethod httpMethod, String urlPath, boolean cached) throws IOException
  {
    Preconditions.checkState(lifecycleLock.awaitStarted(1, TimeUnit.MILLISECONDS));
    return new Request(httpMethod, new URL(StringUtils.format("%s%s", getCurrentKnownLeader(cached), urlPath)));
  }
495462
function ensureBufferSize(buffer, minimumSize, contentSize) {
        if (buffer.length >= minimumSize) {
            return buffer;
        }
        var newBuffer = new Buffer(minimumSize);
        if (contentSize) {
            buffer.copy(newBuffer, 0, 0, contentSize);
        } else {
            buffer.copy(newBuffer);
        }
        return newBuffer;
    }
651576
def request(new_url, shrinker)
      shrinker.url = new_url
      Typhoeus::Request.new(
        shrinker.api_url,
        method:  shrinker.http_method,
        body:    shrinker.body_parameters(shrinker.url),
        headers: { 'Content-Type' => shrinker.content_type }
      ).run
    end
464446
public static IoBufferEx getBufferForFile(IoBufferAllocatorEx<?> allocator, File requestFile) throws IOException {
        FileInputStream in = new FileInputStream(requestFile);
        IoBufferEx out = allocator.wrap(allocator.allocate(in.available())).setAutoExpander(allocator);
        try {
            int pos = out.position();
            byte[] buf = new byte[1024 * 8];
            int length;
            while ((length = in.read(buf)) > 0) {
                out.put(buf, 0, length);
            }
            out.position(pos);
        } finally {
            in.close();
        }

        return out;
    }
348751
public com.google.appengine.v1.CreateVersionRequest getRequest() {
    return request_ == null ? com.google.appengine.v1.CreateVersionRequest.getDefaultInstance() : request_;
  }
227025
private void grow(int neededSize) {
    if (neededSize > ARRAY_MAX - totalSize()) {
      throw new UnsupportedOperationException(
        "Cannot grow internal buffer by size " + neededSize + " because the size after growing " +
          "exceeds size limitation " + ARRAY_MAX);
    }
    final int length = totalSize() + neededSize;
    if (buffer.length < length) {
      int newLength = length < ARRAY_MAX / 2 ? length * 2 : ARRAY_MAX;
      final byte[] tmp = new byte[newLength];
      Platform.copyMemory(
        buffer,
        Platform.BYTE_ARRAY_OFFSET,
        tmp,
        Platform.BYTE_ARRAY_OFFSET,
        totalSize());
      buffer = tmp;
    }
  }
2357
static ByteBuffer getTemporaryDirectBuffer(int size) {
        BufferCache cache = bufferCache.get();
        ByteBuffer buf = cache.get(size);
        if (buf != null) {
            return buf;
        } else {
            // No suitable buffer in the cache so we need to allocate a new
            // one. To avoid the cache growing then we remove the first
            // buffer from the cache and free it.
            if (!cache.isEmpty()) {
                buf = cache.removeFirst();
                free(buf);
            }
            return ByteBuffer.allocateDirect(size);
        }
    }
14315
public char[] allocSmallCBuffer(int minSize)
    {
        if (mCurrRecycler != null) {
            char[] result = mCurrRecycler.getSmallCBuffer(minSize);
            if (result != null) {
                return result;
            }
        }
        // Nope; no recycler, or it has no suitable buffers, let's create:
        return new char[minSize];
    }