Atari ST series Technical Reference Manual page 289

Hide thumbs Also See for ST series:
Table of Contents

Advertisement

Malloc()
U s e d to a l l o c a t e s o m e o f t h e s y s t e m 's f r e e m e m o r y , a n d r e s e r v e it f o r u s e
b y t h e p r o g r a m . A f t e r t h e p r o g r a m is f in i s h e d u s i n g t h e m e m o r y , it s h o u l d
r e t u r n it w i t h M f r e e ( ) . M a l l o c ( ) c a n a l s o b e u s e d to d e t e r m i n e th e s iz e o f
t h e l a r g e s t b l o c k o f m e m o r y in t h e f r e e m e m o r y p o o l . B e c a u s e o f a b u g in
M a l l o c ( ) , p r o g r a m s s h o u l d t r y t o g e t a ll t h e m e m o r y t h e y n e e d w i t h o n e
b i g M a l l o c ( ) c a ll, i n s t e a d o f s e v e r a l little o n e s .
C macro format
l o n g a d d r e s s , b y t e s ;
a d d r e s s =
M a l l o c ( b y t e s ) ;
Machine language format
m o v e . 1
# b y t e s , - (s p )
m o v e , w
# $ 4 8 , - (s p )
t r a p
# 1
a d d q .l
# 6 , s p
Inputs
b y t e s
l o n g
Results
DO
a d d r e s s
l o n g
See also
M f r e e ( )
Malloc
Allocate Memory Block
T h e n u m b e r o f b y t e s o f m e m o r y to a ll o ­
c a t e . I f s e t to - 1 , t h e f u n c t i o n r e t u r n s
t h e s i z e o f t h e l a r g e s t b l o c k o f f r e e m e m ­
o r y in
If t h e f u n c t i o n is a b l e t o a l l o c a t e
m e m o r y , t h e s t a r t i n g a d d r e s s o f t h e m e m o r y b l o c k
is r e t u r n e d h e r e . I f t h e r e i s n 't s u f f i c i e n t f r e e m e m ­
o r y t o a l l o c a t e t h e b l o c k t h a t w a s r e q u e s t e d , a v a l u e
o f 0 is r e t u r n e d .
Opcode = 72 ($48)
address.
bytes
a m o u n t o f
281

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents