public synchronized void free(long pos,int length){
  int start=getBlock(pos);
  int blocks=getBlockCount(length);
  BlockRange x=new BlockRange(start,blocks);
  BlockRange next=freeSpace.ceiling(x);
  if (next == null) {
    throw DataUtils.newIllegalStateException(DataUtils.ERROR_INTERNAL,"Free space sentinel is missing");
  }
  BlockRange prev=freeSpace.lower(x);
  if (prev != null) {
    if (prev.start + prev.blocks == start) {
      prev.blocks+=blocks;
      if (prev.start + prev.blocks == next.start) {
        prev.blocks+=next.blocks;
        freeSpace.remove(next);
      }
      return;
    }
  }
  if (start + blocks == next.start) {
    next.start-=blocks;
    next.blocks+=blocks;
    return;
  }
  freeSpace.add(x);
}

public synchronized void free ( long pos , int length ) { int start = getBlock ( pos ) ; int blocks = getBlockCount ( length ) ; BlockRange x = new BlockRange ( start , blocks ) ; BlockRange next = freeSpace . ceiling ( x ) ; if ( next == null ) { throw DataUtils . newIllegalStateException ( DataUtils . ERROR_INTERNAL , "Free space sentinel is missing" ) ; } BlockRange prev = freeSpace . lower ( x ) ; if ( prev != null ) { if ( prev . start + prev . blocks == start ) { prev . blocks += blocks ; if ( prev . start + prev . blocks == next . start ) { prev . blocks += next . blocks ; freeSpace . remove ( next ) ; } return ; } } if ( start + blocks == next . start ) { next . start -= blocks ; next . blocks += blocks ; return ; } freeSpace . add ( x ) ; }
mark the space as free .
