private int generateUserMemoryAddress(PartitionRecord partitionRecord) { int memoryShift = 0; foreach (PartitionRecord record in simulatorModel.Partitions) { memoryShift += record.Size; if (record.Equals(partitionRecord)) { return memoryShift; } } return memoryShift; }
private void AllocateSpaceOnPartition(PartitionRecord freePartitionToUse, AllocateAction allocateAction) { int partitionIndex = Partitions.IndexOf(freePartitionToUse); int difference = freePartitionToUse.Size - allocateAction.RequiredSize; Partitions.RemoveAt(partitionIndex); if (difference > 0) { Partitions.Insert(partitionIndex, new PartitionRecord(freePartitionToUse.Size - allocateAction.RequiredSize)); } Partitions.Insert(partitionIndex, new PartitionRecord(allocateAction.RequiredSize, allocateAction.AllocatedNewSpaceId)); }