Nand2Tetris Questions and Answers Forum
›
Operating System
›
Project 12
Search
everywhere
only in this topic
Advanced Search
How to return a failure if no segment is found?
Classic
List
Threaded
♦
♦
Locked
2 messages
kraftwerk1611
Reply
|
Threaded
Open this post in threaded view
♦
♦
|
How to return a failure if no segment is found?
This post was updated on
.
Hi,
What is the right way for function alloc()to return a failure to the caller, when no memory segment of the required size is found?
Is returning a value of 0 ok, when false=0 and true=-1?
thanks.
cadet1620
Reply
|
Threaded
Open this post in threaded view
♦
♦
|
Re: How to return a failure if no segment is found?
Administrator
The specification says that you should call Sys.error(6) if the allocation request cannot be satisfied.
That said, my Memory.jack has a returnErrors(boolean) function that enables alloc() to return 0 when memory requests cannot be satisfied.
--Mark
Free forum by Nabble
Edit this page