MCPcopy Index your code
hub / github.com/apache/tomcat / expand

Method expand

java/org/apache/tomcat/util/buf/ByteBufferUtils.java:39–62  ·  view source on GitHub ↗

Expands buffer to the given size unless it is already as big or bigger. Buffers are assumed to be in 'write to' mode since there would be no need to expand a buffer while it was in 'read from' mode. @param in Buffer to expand @param newSize The size t which the buffer should be expanded @retu

(ByteBuffer in, int newSize)

Source from the content-addressed store, hash-verified

37 * was no need for expansion
38 */
39 public static ByteBuffer expand(ByteBuffer in, int newSize) {
40 if (in.capacity() >= newSize) {
41 return in;
42 }
43
44 ByteBuffer out;
45 boolean direct = false;
46 if (in.isDirect()) {
47 out = ByteBuffer.allocateDirect(newSize);
48 direct = true;
49 } else {
50 out = ByteBuffer.allocate(newSize);
51 }
52
53 // Copy data
54 in.flip();
55 out.put(in);
56
57 if (direct) {
58 cleanDirectBuffer(in);
59 }
60
61 return out;
62 }
63
64 /**
65 * Clean specified direct buffer. This will cause an unavoidable warning on Java 24 and newer.

Callers 4

processSNIMethod · 0.95
processSNIMethod · 0.95
expandMethod · 0.95
readHeaderPayloadMethod · 0.95

Calls 4

cleanDirectBufferMethod · 0.95
flipMethod · 0.80
allocateMethod · 0.65
putMethod · 0.65

Tested by

no test coverage detected