def allocate(self, address, memory):
    if ((address < 0) or (memory <= 0)):
        raise ValueError('Address or memory amount to be allocated in the Virtual Memory instance can not be negative.')
    if ((address + memory) > self.max_memory):
        raise IndexError((((((('Can not allocate virtual_memory_chunks to an address outside the max_memory range of the Virtual_Memory instance.' + 'Attempted to allocate at ') + str(hex(address))) + ' for ') + str(hex(memory))) + ' bytes. max_memory of the current Virtual_Memory instance is ') + str(hex(self.max_memory))))
    if (len(self.chunks) > 0):
        for chunk in range(0, len(self.chunks)):
            if (((address < self.chunks[chunk][1]) and ((address + memory) >= self.chunks[chunk][1])) or ((address >= self.chunks[chunk][1]) and (address <= (self.chunks[chunk][1] + self.chunks[chunk][2])))):
                raise IndexError((((((((('Cannot allocate to an already allocated address. Allocation: Address: ' + str(hex(address))) + ', Memory: ') + str(hex(memory))) + ' Overlaps allocation at ') + str(hex(self.chunks[chunk][1]))) + ' for ') + str(hex(self.chunks[chunk][2]))) + ' Bytes.'))
            self.chunks.append((Virtual_Memory_Chunk(self, address, memory), address, memory))
    else:
        self.chunks.append((Virtual_Memory_Chunk(self, address, memory), address, memory))
def allocate(self, address, memory):
    if ((address < 0) or (memory <= 0)):
        raise ValueError('Address or memory amount to be allocated in the Virtual Memory instance can not be negative.')
    if ((address + memory) > self.max_memory):
        raise IndexError((((((('Can not allocate virtual_memory_chunks to an address outside the max_memory range of the Virtual_Memory instance.' + 'Attempted to allocate at ') + str(hex(address))) + ' for ') + str(hex(memory))) + ' bytes. max_memory of the current Virtual_Memory instance is ') + str(hex(self.max_memory))))
    if (len(self.chunks) > 0):
        for chunk in range(0, len(self.chunks)):
            if (((address < self.chunks[chunk][1]) and ((address + memory) >= self.chunks[chunk][1])) or ((address >= self.chunks[chunk][1]) and (address <= (self.chunks[chunk][1] + self.chunks[chunk][2])))):
                raise IndexError((((((((('Cannot allocate to an already allocated address. Allocation: Address: ' + str(hex(address))) + ', Memory: ') + str(hex(memory))) + ' Overlaps allocation at ') + str(hex(self.chunks[chunk][1]))) + ' for ') + str(hex(self.chunks[chunk][2]))) + ' Bytes.'))
            self.chunks.append((Virtual_Memory_Chunk(self, address, memory), address, memory))
    else:
        self.chunks.append((Virtual_Memory_Chunk(self, address, memory), address, memory))