[Overview][Constants][Types][Procedures and functions][Index] Reference for unit 'Exec' (#aros)


Allocate a block of memory


Source position: exec.pas line 1239

function Allocate(

  FreeList: PMemHeader;

  ByteSize: ULONG





Pointer to the local memory list header.



Size of the desired block in bytes.

Function result

A pointer to the just allocated free block. If there are no free regions large enough to satisfy the request, return nil.


This function is used to allocate blocks of memory from a given private free memory pool (as specified by a MemHeader and its memory chunk list). Allocate will return the first free block that is greater than or equal to the requested size.

All blocks, whether free or allocated, will be block aligned; hence, all allocation sizes are rounded up to the next block even value (e.g. the minimum allocation resolution is currently 8 bytes. A request for 8 bytes will use up exactly 8 bytes. A request for 7 bytes will also use up exactly 8 bytes.).

This function can be used to manage an application's internal data memory. Note that no arbitration of the MemHeader and associated free chunk list is done. You must be the owner before calling Allocate.


If the free list is corrupt, the system will panic with alert AN_MemCorrupt, $01000005.

See also



Free a block of memory

Documentation generated on: 2017-01-10