•  Back 
  •  GEMDOS Function Reference 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  %About 
  •  Show info about hypertext 
  •  View a new file 
Topic       : The ATARI Compendium
Author      : Scott Sanders / JAY Software
Version     : 1.25 (20/6/2003)
Subject     : Documentation
Nodes       : 1117
Index Size  : 32614
HCP-Version : 6
Compiled on : Atari
@charset    : UTF-8
@lang       : en
@default    : 
@help       : %About
@options    : +g -i -t4 +y +z
@width      : 100
View Ref-FileMxalloc()
Malloc()                                                             GEMDOS

Syntax

VOIDP Malloc( amount )
LONG amount;

Function      Malloc() requests a block of memory for use by an
              application.

Opcode        72 (0x48)

Availability  All GEMDOS versions.

Parameters    amount specifies the amount of memory (in bytes) you wish to
              allocate. You may pass a value of -1L in which case the
              function will return the size of the largest free block of
              memory.

Binding       move.l   amount,-(sp)
              move.w   #$48,-(sp)
              trap     #1
              addq.l   #6,sp

Return Value  Malloc() returns NULL if there is no block large enough to
              fill the request or a pointer to the block if the request
              was satisfied. The memory allocated will be chosen based on
              the status of the processes' load flags. To specify the
              memory requirements in more detail, use Mxalloc().

Caveats       Prior to GEMDOS version 0.15, Malloc( 0L ) will return
              a pointer to invalid memory as opposed to failing as it
              should.

Comments      Because GEMDOS can only allocate a limited amount of blocks
              per process (as few as 20 depending on the version of
              GEMDOS), applications should limit their usage of this call
              by allocating a few large blocks instead of many small
              blocks or use a 'C' memory manager (like malloc() ) if
              possible.

See Also      Mxalloc()