ensureWritable0() — netty Function Reference
Architecture documentation for the ensureWritable0() function in AbstractByteBuf.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 287b7ae4_08b2_7835_1a21_05b041594575["ensureWritable0()"] bbab270f_457a_3319_83a8_0a0540484666["AbstractByteBuf"] 287b7ae4_08b2_7835_1a21_05b041594575 -->|defined in| bbab270f_457a_3319_83a8_0a0540484666 e9e1f861_5813_ec75_8a61_6b29c497ac9f["ByteBuf()"] e9e1f861_5813_ec75_8a61_6b29c497ac9f -->|calls| 287b7ae4_08b2_7835_1a21_05b041594575 0afa27e0_95ae_86b1_18d2_87db939fb93c["setCharSequence0()"] 0afa27e0_95ae_86b1_18d2_87db939fb93c -->|calls| 287b7ae4_08b2_7835_1a21_05b041594575 67993e0c_3b33_e884_495b_6ad7509b65c8["writerIndex()"] 287b7ae4_08b2_7835_1a21_05b041594575 -->|calls| 67993e0c_3b33_e884_495b_6ad7509b65c8 6d7a760c_9235_3c42_7498_04dce6863295["ensureAccessible()"] 287b7ae4_08b2_7835_1a21_05b041594575 -->|calls| 6d7a760c_9235_3c42_7498_04dce6863295 f4e37074_4ad7_6a4d_b116_3b334abcf18d["maxCapacity()"] 287b7ae4_08b2_7835_1a21_05b041594575 -->|calls| f4e37074_4ad7_6a4d_b116_3b334abcf18d style 287b7ae4_08b2_7835_1a21_05b041594575 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
buffer/src/main/java/io/netty/buffer/AbstractByteBuf.java lines 284–306
final void ensureWritable0(int minWritableBytes) {
final int writerIndex = writerIndex();
final int targetCapacity = writerIndex + minWritableBytes;
// using non-short-circuit & to reduce branching - this is a hot path and targetCapacity should rarely overflow
if (targetCapacity >= 0 & targetCapacity <= capacity()) {
ensureAccessible();
return;
}
if (checkBounds && (targetCapacity < 0 || targetCapacity > maxCapacity)) {
ensureAccessible();
throw new IndexOutOfBoundsException(String.format(
"writerIndex(%d) + minWritableBytes(%d) exceeds maxCapacity(%d): %s",
writerIndex, minWritableBytes, maxCapacity, this));
}
// Normalize the target capacity to the power of 2.
final int fastWritable = maxFastWritableBytes();
int newCapacity = fastWritable >= minWritableBytes ? writerIndex + fastWritable
: alloc().calculateNewCapacity(targetCapacity, maxCapacity);
// Adjust to the new capacity.
capacity(newCapacity);
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does ensureWritable0() do?
ensureWritable0() is a function in the netty codebase, defined in buffer/src/main/java/io/netty/buffer/AbstractByteBuf.java.
Where is ensureWritable0() defined?
ensureWritable0() is defined in buffer/src/main/java/io/netty/buffer/AbstractByteBuf.java at line 284.
What does ensureWritable0() call?
ensureWritable0() calls 3 function(s): ensureAccessible, maxCapacity, writerIndex.
What calls ensureWritable0()?
ensureWritable0() is called by 2 function(s): ByteBuf, setCharSequence0.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free