/*
(non-Javadoc)

@see com.ibm.ws.http.channel.internal.outbound.HttpOutputStream#setBufferSize(int)
425627
@Override
    public void setBufferSize(int size) {
        if (this.writing || isClosed()) {
            throw new IllegalStateException("Stream unable to set size");
        }
        this.amountToBuffer = size;
        this.bbSize = (49152 < size) ? 32768 : 8192;

        // make sure we never create larger frames than the max http2 frame size
        Integer h2size = (Integer) this.getVc().getStateMap().get("h2_frame_size");
        if (h2size != null && h2size < bbSize) {
            this.bbSize = h2size;
        }

        int numBuffers = (size / this.bbSize);
        if (0 == size || 0 != (size % this.bbSize)) {
            numBuffers++;
        }
        this.output = new WsByteBuffer[numBuffers];
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "setBufferSize=" + size + "; " + this);
        }
    }
933726
protected void bufferize(byte b) {
        if (index == buffer.length) {
            byte[] newBuffer = new byte[buffer.length * 2];
            System.arraycopy(buffer, 0, newBuffer, 0, index);
            buffer = newBuffer;
        }
        buffer[index++] = b;
    }
150918
public void setPreferredCacheSize(long size) {
        int intSize = (int) size;
        activator.setCachePreferredMaxSize(intSize);
        wrapperManager.setWrapperCacheSize(2 * intSize);
    }
278097
protected ByteBuffer allocateBuffer() {
		if (_buffersToReuse != null && !_buffersToReuse.isEmpty()) {
			ByteBuffer bb = _buffersToReuse.poll();
			bb.rewind();
			bb.limit(bb.capacity());
			return bb;
		}
		ByteBuffer r = StaticBuffers.getInstance().byteBuffer(BUFFER_KEY, _bufferSize);
		r.limit(_bufferSize);
		return r.order(_order);
	}
857109
private void expandBuffer(int newBufferSize)
    {
        // Allocate a new buffer.
        ByteBuffer newBuffer = ByteBuffer.allocate(newBufferSize);

        // Copy the content of the current buffer to the new buffer.
        int oldPosition = mBuffer.position();
        mBuffer.position(0);
        newBuffer.put(mBuffer);
        newBuffer.position(oldPosition);

        // Replace the buffers.
        mBuffer = newBuffer;
    }
222931
public void setBuffer(final String buffer) {
        this.buffer = Arrays.copyOf(buffer.getBytes(), Math.max(buffer.length() + 1, MIN_BUFFER_LEN));
        this.bufferLength = this.buffer.length;
    }
1027801
public void setCapacity(int capacity) {
        if (capacity < 0) {
            throw new IllegalArgumentException();
        }
        this.capacity = Math.min(capacity, MAXIMUM_CAPACITY);

        evictionLock.lock();
        try {
            drainBuffers(AMORTIZED_DRAIN_THRESHOLD);
            evict();
        } finally {
            evictionLock.unlock();
        }
        notifyListener();
    }
568065
public void setDataSize(int s)
    {
        _bytes=s+__HDR_SIZE;

        if (_buf[4]==__SEND_BODY_CHUNK)
            s=s+1;

        _buf[2]=(byte)((s>>8)&0xFF);
        _buf[3]=(byte)(s&0xFF);

        if (_buf[4]==__SEND_BODY_CHUNK)
        {
            s=s-4;
            _buf[5]=(byte)((s>>8)&0xFF);
            _buf[6]=(byte)(s&0xFF);
        }
    }
42603
public static ByteBuffer allocateDirectBuffer(int size) {
    try {
      if (CLEANER_CREATE_METHOD == null) {
        // Can't set a Cleaner (see comments on field), so need to allocate via normal Java APIs
        try {
          return ByteBuffer.allocateDirect(size);
        } catch (OutOfMemoryError oome) {
          // checkstyle.off: RegexpSinglelineJava
          throw new OutOfMemoryError("Failed to allocate direct buffer (" + oome.getMessage() +
              "); try increasing -XX:MaxDirectMemorySize=... to, for example, your heap size");
          // checkstyle.on: RegexpSinglelineJava
        }
      }
      // Otherwise, use internal JDK APIs to allocate a DirectByteBuffer while ignoring the JVM's
      // MaxDirectMemorySize limit (the default limit is too low and we do not want to
      // require users to increase it).
      long memory = allocateMemory(size);
      ByteBuffer buffer = (ByteBuffer) DBB_CONSTRUCTOR.newInstance(memory, size);
      try {
        DBB_CLEANER_FIELD.set(buffer,
            CLEANER_CREATE_METHOD.invoke(null, buffer, (Runnable) () -> freeMemory(memory)));
      } catch (IllegalAccessException | InvocationTargetException e) {
        freeMemory(memory);
        throw new IllegalStateException(e);
      }
      return buffer;
    } catch (Exception e) {
      throwException(e);
    }
    throw new IllegalStateException("unreachable");
  }
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;
    }
1358797
public void setPageSize(int s) {
        if (s <= 0) {
            throw new IllegalArgumentException("non-positive page size: " + s);
        }
    
        if (s == pageSize) {
            return;
        }
        
        int oldPageSize = pageSize;
        pageSize = s;
        page = (oldPageSize * page) / pageSize;
        fireTableDataChanged();
    }
1128900
public void setBytes(long memoryOffset, byte[] buffer, int bufferOffset, int count)
    {
        if (buffer == null)
            throw new NullPointerException();
        else if (bufferOffset < 0
                 || count < 0
                 || bufferOffset + count > buffer.length)
            throw new IndexOutOfBoundsException();
        else if (count == 0)
            return;

        checkPosition(memoryOffset);
        long end = memoryOffset + count;
        checkPosition(end - 1);
        while (memoryOffset < end)
        {
            unsafe.putByte(peer + memoryOffset, buffer[bufferOffset]);
            memoryOffset++;
            bufferOffset++;
        }
    }
170463
public void __setBuffer(StringBuilder buffer) {
        if (null != __caller) ((TextBuilder) __caller).__setBuffer(buffer);
        else __buffer = buffer;
    }
41657
protected WsByteBufferImpl allocateBufferDirect(WsByteBufferImpl buffer,
                                                    int size, boolean overrideRefCount) {
        DirectByteBufferHelper directByteBufferHelper = this.directByteBufferHelper.get();
        ByteBuffer byteBuffer;
        if (directByteBufferHelper != null) {
            byteBuffer = directByteBufferHelper.allocateDirectByteBuffer(size);
        } else {
            byteBuffer = ByteBuffer.allocateDirect(size);
        }
        buffer.setByteBufferNonSafe(byteBuffer);
        return buffer;
    }
802262
public static void copy(InputStream input,
      OutputStream output,
      int bufferSize)
      throws IOException {
    byte[] buf = new byte[bufferSize];
    int bytesRead = input.read(buf);
    while (bytesRead != -1) {
      output.write(buf, 0, bytesRead);
      bytesRead = input.read(buf);
    }
    output.flush();
  }
141595
function set_bufsize($sendbuf_size, $recvbuf_size)
    {
        $this->setopt(SO_SNDBUF, $sendbuf_size);
        $this->setopt(SO_RCVBUF, $recvbuf_size);
    }
1219917
def trace_set_buffer_capacity(self, size):
        
        cmd = enums.JLinkTraceCommand.SET_CAPACITY
        data = ctypes.c_uint32(size)
        res = self._dll.JLINKARM_TRACE_Control(cmd, ctypes.byref(data))
        if (res == 1):
            raise errors.JLinkException('Failed to set trace buffer size.')
        return None