Home / Function/ chooseFirstFreeBuddy() — netty Function Reference

chooseFirstFreeBuddy() — netty Function Reference

Architecture documentation for the chooseFirstFreeBuddy() function in AdaptivePoolingAllocator.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  09ad62f1_655a_04ec_8e0e_51a3c352654d["chooseFirstFreeBuddy()"]
  fbf1f415_2f80_8493_e5fb_f8f9be5f99ee["BuddyChunk"]
  09ad62f1_655a_04ec_8e0e_51a3c352654d -->|defined in| fbf1f415_2f80_8493_e5fb_f8f9be5f99ee
  a13d9512_d928_e5c6_faed_67181d87b829["readInitInto()"]
  a13d9512_d928_e5c6_faed_67181d87b829 -->|calls| 09ad62f1_655a_04ec_8e0e_51a3c352654d
  style 09ad62f1_655a_04ec_8e0e_51a3c352654d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java lines 1458–1479

        private int chooseFirstFreeBuddy(int index, int size, int currOffset) {
            byte[] buddies = this.buddies;
            while (index < buddies.length) {
                byte buddy = buddies[index];
                int currValue = MIN_BUDDY_SIZE << (buddy & SHIFT_MASK);
                if (currValue < size || (buddy & IS_CLAIMED) == IS_CLAIMED) {
                    return -1;
                }
                if (currValue == size && (buddy & HAS_CLAIMED_CHILDREN) == 0) {
                    buddies[index] |= IS_CLAIMED;
                    return currOffset;
                }
                int found = chooseFirstFreeBuddy(index << 1, size, currOffset);
                if (found != -1) {
                    buddies[index] |= HAS_CLAIMED_CHILDREN;
                    return found;
                }
                index = (index << 1) + 1;
                currOffset += currValue >> 1; // Bump offset to skip first half of this layer.
            }
            return -1;
        }

Domain

Subdomains

Called By

Frequently Asked Questions

What does chooseFirstFreeBuddy() do?
chooseFirstFreeBuddy() is a function in the netty codebase, defined in buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java.
Where is chooseFirstFreeBuddy() defined?
chooseFirstFreeBuddy() is defined in buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java at line 1458.
What calls chooseFirstFreeBuddy()?
chooseFirstFreeBuddy() is called by 1 function(s): readInitInto.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free