parameters: (self, bytes, block=None)
return_statement: return block
docstring: Allocate or reallocate a block such that it has space for at least
          `bytes' bytes.
docstring_summary: Allocate or reallocate a block such that it has space for at least
          `bytes' bytes.
docstring_tokens: Allocate or reallocate a block such that it has space for at least bytes bytes .
function: def allocate(self, bytes, block=None):
          """Allocate or reallocate a block such that it has space for at least
          `bytes' bytes."""
          if block is None:
              # Find the first unused block
              try:
                  block = self._offsets.index(0)
              except ValueError:
                  block = len(self._offsets)
                  self._offsets.append(0)
          
          # Compute block width
          width = max(bytes.bit_length(), 5)
  
          addr = self._offsets[block]
          offset = addr & ~0x1f
          
          if addr:
              blkwidth = addr & 0x1f
              if blkwidth == width:
                  return block
              self._release(offset, width)
              self._offsets[block] = 0
  
          offset = self._alloc(width)
          self._offsets[block] = offset | width
          return block
function_tokens: def allocate ( self , bytes , block = None ) : if block is None : # Find the first unused block try : block = self . _offsets . index ( 0 ) except ValueError : block = len ( self . _offsets ) self . _offsets . append ( 0 ) # Compute block width width = max ( bytes . bit_length ( ) , 5 ) addr = self . _offsets [ block ] offset = addr & ~ 0x1f if addr : blkwidth = addr & 0x1f if blkwidth == width : return block self . _release ( offset , width ) self . _offsets [ block ] = 0 offset = self . _alloc ( width ) self . _offsets [ block ] = offset | width return block