pub fn alloc(
    memory: &mut MemoryTable,
    process: &mut Memory,
    address: Address,
    index: usize,
) -> usize {
    let end = address + process.size;
    process.address.start = address;
    process.address.end = end.clone();

    let mut after_block = memory.remove(index).unwrap_or_default();
    let size = after_block.size;
    after_block.address.start += process.size;
    after_block.set_size(size - process.size);

    memory.insert(index, *process);
    if after_block.size > 0 {
        memory.insert(index + 1, after_block);
    }
    return if memory.len() - 1 > index {
        index + 1
    } else {
        index
    };
}
/// return index number of next number
return index number of next number
return index number of next number
pub fn alloc(
    memory: &mut MemoryTable,
    process: &mut Memory,
    address: Address,
    index: usize,
) -> usize {
    let end = address + process.size;
    process.address.start = address;
    process.address.end = end.clone();
    let mut after_block = memory.remove(index).unwrap_or_default();
    let size = after_block.size;
    after_block.address.start += process.size;
    after_block.set_size(size - process.size);
    memory.insert(index, *process);
    if after_block.size > 0 {
        memory.insert(index + 1, after_block);
    }
    return if memory.len() - 1 > index {
        index + 1
    } else {
        index
    };
}
pub fn alloc ( memory : & mut MemoryTable , process : & mut Memory , address : Address , index : usize , ) -> usize { let end = address + process . size ; process . address . start = address ; process . address . end = end . clone ( ) ; let mut after_block = memory . remove ( index ) . unwrap_or_default ( ) ; let size = after_block . size ; after_block . address . start += process . size ; after_block . set_size ( size - process . size ) ; memory . insert ( index , * process ) ; if after_block . size > 0 { memory . insert ( index + 1 , after_block ) ; } return if memory . len ( ) - 1 > index { index + 1 } else { index } ; }
return index number of next number
return index number of next number
memory
&mut MemoryTable
process
&mut Memory
address
Address
index
usize