reallocIfNeeded() — netty Function Reference
Architecture documentation for the reallocIfNeeded() function in NativeLongArray.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 682814d5_3a6f_0320_6ddc_71156d6dbd53["reallocIfNeeded()"] d17350c3_e125_2323_980a_eae0f43600f1["NativeLongArray"] 682814d5_3a6f_0320_6ddc_71156d6dbd53 -->|defined in| d17350c3_e125_2323_980a_eae0f43600f1 585f855d_185a_e249_9bc8_6e1397074cb7["add()"] 585f855d_185a_e249_9bc8_6e1397074cb7 -->|calls| 682814d5_3a6f_0320_6ddc_71156d6dbd53 ecba7f48_0fcf_5ca2_15c1_8da94f0bbce8["calculateBufferCapacity()"] 682814d5_3a6f_0320_6ddc_71156d6dbd53 -->|calls| ecba7f48_0fcf_5ca2_15c1_8da94f0bbce8 2f42ea99_3a54_c982_26b6_4f5d891044d0["memoryAddress()"] 682814d5_3a6f_0320_6ddc_71156d6dbd53 -->|calls| 2f42ea99_3a54_c982_26b6_4f5d891044d0 style 682814d5_3a6f_0320_6ddc_71156d6dbd53 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/NativeLongArray.java lines 88–106
private void reallocIfNeeded() {
if (size == capacity) {
// Double the capacity while it is "sufficiently small", and otherwise increase by 50%.
int newLength = capacity <= 65536 ? capacity << 1 : capacity + capacity >> 1;
int newCapacity = calculateBufferCapacity(newLength);
CleanableDirectBuffer buffer = Buffer.allocateDirectBufferWithNativeOrder(newCapacity);
// Copy over the old content of the memory and reset the position as we always act on the buffer as if
// the position was never increased.
memory.position(0).limit(size);
buffer.buffer().put(memory);
buffer.buffer().position(0);
memoryCleanable.clean();
memoryCleanable = buffer;
memory = buffer.buffer();
memoryAddress = Buffer.memoryAddress(memory);
capacity = newLength;
}
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does reallocIfNeeded() do?
reallocIfNeeded() is a function in the netty codebase, defined in transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/NativeLongArray.java.
Where is reallocIfNeeded() defined?
reallocIfNeeded() is defined in transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/NativeLongArray.java at line 88.
What does reallocIfNeeded() call?
reallocIfNeeded() calls 2 function(s): calculateBufferCapacity, memoryAddress.
What calls reallocIfNeeded()?
reallocIfNeeded() is called by 1 function(s): add.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free