Memory allocation: Difference between revisions

Content added Content deleted
m (→‎{{header|Retro}}: update for retro12)
Line 1,261: Line 1,261:


=={{header|Retro}}==
=={{header|Retro}}==
Retro's memory is directly accessible via '''@''' and '''!'''. This is used for all functions and data structures. A variable, '''heap''', points to the next free address. '''allot''' can be used to allocate or free memory. The amount of memory varies by the runtime, and can be accessed via the '''memory''' variable.
Retro's memory is directly accessible via '''fetch''' and '''store'''. This is used for all functions and data structures. A variable, '''Heap''', points to the next free address. '''allot''' can be used to allocate or free memory. The amount of memory varies by the runtime, and can be accessed via the '''EOM''' constant.


<lang Retro>( display total memory available )
<lang Retro>display total memory available
@memory putn


~~~
( display unused memory )
EOM n:put
@memory here - putn
~~~


( display next free address )
display unused memory
here putn


~~~
( allocate 1000 cells )
EOM here - n:put
1000 allot
~~~


( free 500 cells )
display next free address

-500 allot</lang>
~~~
here n:put
~~~

allocate 1000 cells

~~~
#1000 allot
~~~

free 500 cells

~~~
#-500 allot
~~~</lang>


=={{header|REXX}}==
=={{header|REXX}}==