code: public synchronized void allocate(RegularFile file, int count) throws IOException {
      int newAllocatedBlockCount = allocatedBlockCount + count;
      if (newAllocatedBlockCount > maxBlockCount) {
        throw new IOException("out of disk space");
      }
  
      int newBlocksNeeded = Math.max(count - blockCache.blockCount(), 0);
  
      for (int i = 0; i < newBlocksNeeded; i++) {
        file.addBlock(new byte[blockSize]);
      }
  
      if (newBlocksNeeded != count) {
        blockCache.transferBlocksTo(file, count - newBlocksNeeded);
      }
  
      allocatedBlockCount = newAllocatedBlockCount;
    }
docs: Allocates the given number of blocks and adds them to the given file.