realloc() — netty Function Reference
Architecture documentation for the realloc() function in KQueueEventArray.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 12daeba4_d43b_3906_87d8_7fd36d2c180c["realloc()"] 43377ca2_4201_bd6f_4ef1_60f1c213f5b8["KQueueEventArray"] 12daeba4_d43b_3906_87d8_7fd36d2c180c -->|defined in| 43377ca2_4201_bd6f_4ef1_60f1c213f5b8 a1b74c4f_782b_17ec_ce12_454a1941b54e["reallocIfNeeded()"] a1b74c4f_782b_17ec_ce12_454a1941b54e -->|calls| 12daeba4_d43b_3906_87d8_7fd36d2c180c 7961ca17_85c8_dffa_200d_db4a49163083["calculateBufferCapacity()"] 12daeba4_d43b_3906_87d8_7fd36d2c180c -->|calls| 7961ca17_85c8_dffa_200d_db4a49163083 bd9f9cf8_bce0_44d0_2739_c95afb0494e6["memoryAddress()"] 12daeba4_d43b_3906_87d8_7fd36d2c180c -->|calls| bd9f9cf8_bce0_44d0_2739_c95afb0494e6 style 12daeba4_d43b_3906_87d8_7fd36d2c180c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/KQueueEventArray.java lines 100–125
void realloc(boolean throwIfFail) {
// Double the capacity while it is "sufficiently small", and otherwise increase by 50%.
int newLength = capacity <= 65536 ? capacity << 1 : capacity + capacity >> 1;
try {
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);
} catch (OutOfMemoryError e) {
if (throwIfFail) {
OutOfMemoryError error = new OutOfMemoryError(
"unable to allocate " + newLength + " new bytes! Existing capacity is: " + capacity);
error.initCause(e);
throw error;
}
}
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does realloc() do?
realloc() is a function in the netty codebase, defined in transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/KQueueEventArray.java.
Where is realloc() defined?
realloc() is defined in transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/KQueueEventArray.java at line 100.
What does realloc() call?
realloc() calls 2 function(s): calculateBufferCapacity, memoryAddress.
What calls realloc()?
realloc() is called by 1 function(s): reallocIfNeeded.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free