lib/memory.rb
# Give up frames to allocate the requested amount of memory
#
# @param amount [Integer] the amount of memory to allocate
#
# @return [Array] the frames that can be used to grant the request
Give up frames to allocate the requested amount of memory
Give up frames to allocate the requested amount of memory
def allocate!(amount:)
    frames_needed = (amount / @frame_size) +
                    ((amount % @frame_size).zero? ? 0 : 1)
    if frames_needed > free_frames.size
      raise InsufficientMemoryError, 'Not Enough Memory'
    end
    @free_frames.shift frames_needed
  end
def allocate! ( amount : ) frames_needed = ( amount / @frame_size ) + ( ( amount % @frame_size ) . zero? ? 0 : 1 ) if frames_needed > free_frames . size raise InsufficientMemoryError , 'Not Enough Memory' end @free_frames . shift frames_needed end
Give up frames to allocate the requested amount of memory
Give up frames to allocate the requested amount of memory
the frames that can be used to grant the request
the frames that can be used to grant the request
Array
amount
the amount of memory to allocate
the amount of memory to allocate