private void addToFreeListWithMerge(int headerIx, int freeListIx, CasLog.Src src) {
      while (true) {
        FreeList freeList = freeLists[freeListIx];
        int bHeaderIx = getBuddyHeaderIx(freeListIx, headerIx);
        freeList.lock.lock();
        try {
          if ((freeListIx == freeLists.length - 1)
            || headers[bHeaderIx] != makeHeader(freeListIx, false)) {
            // Buddy block is allocated, or it is on higher level of allocation than we are, or we
            // have reached the top level. Add whatever we have got to the current free list.
            addBlockToFreeListUnderLock(freeList, headerIx, freeListIx);
            setHeaderFree(headerIx, freeListIx, src);
            break;
          }
          // Buddy block is free and in the same free list we have locked. Take it out for merge.
          removeBlockFromFreeList(freeList, bHeaderIx, freeListIx);
          unsetHeader(bHeaderIx, src); // Erase both headers of the blocks to merge.
          unsetHeader(headerIx, src);
        } finally {
          freeList.lock.unlock();
        }
        ++freeListIx;
        headerIx = Math.min(headerIx, bHeaderIx);
      }
    }
Unsets the headers (meaning this does not refer to a buffer).
llap-server/src/java/org/apache/hadoop/hive/llap/cache/BuddyAllocator.java