Unit 'Exec' Package
[Overview][Constants][Types][Procedures and functions][Variables][Index] [#aros]

Allocate

Allocate a block of memory

Declaration

Source position: exec.pas line 1242

function Allocate(

  FreeList: PMemHeader;

  ByteSize: LongWord

):PMemHeader;

Arguments

FreeList

  

Pointer to the local memory list header.

ByteSize

  

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.

Description

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.

Errors

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

See also

Deallocate

  

Free a block of memory


Documentation generated on: 2021-07-30