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-FileMalloc()Mfree()Mxalloc() GEMDOSSyntaxVOIDP Mxalloc( amount, mode )
LONG amount;
WORD mode;
Function Mxalloc() allocates a block of memory according to specified
preferences.
Opcode 68 (0x44)
Availability Available from GEMDOS version 0.19.
Parameters amount specifies the length (in bytes) of the block
requested. As with Malloc(), specifying -1L for amount will
return the size of the largest block of memory available.
With modes 0 or 1, the size of the largest block of
available RAM from the specified type of RAM is returned.
Modes 2 and 3 return the size of the largest available block
or whichever type of RAM had the largest block. mode is
a WORD bit array which specifies the type of memory
requested as follows:
Bit Meaning
0-1 Bits 0-1 represent a possible value of 0-3
representing the type of RAM to allocate as follows:
Name Value Meaning
MX_STRAM 0 Allocate only ST-RAM
MX_TTRAM 1 Allocate only TT-RAM
MX_PREFSTRAM 2 Allocate either, preferring ST-RAM
MX_PREFTTRAM 3 Allocate either, preferring TT-RAM
2 Not used (should be set to 0).
3 If set, refer to bits 4-7 for memory protection
advice, otherwise default to protection specified in
program header. This bit is only valid in the
presence of MiNT.
4-7 Bits 4-7 represent a possible value of 0-7
representing the memory protection mode to place on
the allocated block of memory. Currently valid values
are:
Name Value Meaning
MX_HEADER 0 Refer to Program Header
MX_PRIVATE 1 Private
MX_GLOBAL 2 Global
MX_SUPERVISOR 3 Supervisor Mode Only Access
MX_READABLE 4 Read Only Access
These bits are only consulted if bit 3 is set and
MiNT is present.
8-15 Not used (should be set to 0).
Binding move.w mode,-(sp)
move.l amount,-(sp)
move.w #$44,-(sp)
trap #1
addq.l #8,sp
Return Value Mxalloc() returns NULL if the request could not be granted
or a valid pointer to the start of the block allocated
otherwise.
Comments Mxalloc() should be used instead of Malloc() whenever it is
available.
See Also Malloc(), Mfree()