public synchronized void markUsed(long pos,int length){
  int start=getBlock(pos);
  int blocks=getBlockCount(length);
  BlockRange x=new BlockRange(start,blocks);
  BlockRange prev=freeSpace.floor(x);
  if (prev == null) {
    throw DataUtils.newIllegalStateException(DataUtils.ERROR_INTERNAL,"Free space already marked");
  }
  if (prev.start == start) {
    if (prev.blocks == blocks) {
      freeSpace.remove(prev);
    }
 else {
      prev.start+=blocks;
      prev.blocks-=blocks;
    }
  }
 else   if (prev.start + prev.blocks == start + blocks) {
    prev.blocks-=blocks;
  }
 else {
    x.start=start + blocks;
    x.blocks=prev.start + prev.blocks - x.start;
    freeSpace.add(x);
    prev.blocks=start - prev.start;
  }
}

public synchronized void markUsed ( long pos , int length ) { int start = getBlock ( pos ) ; int blocks = getBlockCount ( length ) ; BlockRange x = new BlockRange ( start , blocks ) ; BlockRange prev = freeSpace . floor ( x ) ; if ( prev == null ) { throw DataUtils . newIllegalStateException ( DataUtils . ERROR_INTERNAL , "Free space already marked" ) ; } if ( prev . start == start ) { if ( prev . blocks == blocks ) { freeSpace . remove ( prev ) ; } else { prev . start += blocks ; prev . blocks -= blocks ; } } else if ( prev . start + prev . blocks == start + blocks ) { prev . blocks -= blocks ; } else { x . start = start + blocks ; x . blocks = prev . start + prev . blocks - x . start ; freeSpace . add ( x ) ; prev . blocks = start - prev . start ; } }
mark the space as in use .
