Unit 'exec' Package
[Overview][Constants][Types][Procedures and functions][Variables][Index] [#os4units]

ExecAllocMem

Allocate memory given certain requirements

Declaration

Source position: exec.pas line 1753

function ExecAllocMem(

  ByteSize: LongWord;

  Requirements: LongWord

):Pointer;

Arguments

ByteSize

  

The size of the desired block in bytes. (The operating system will automatically round this number to a multiple of the system memory chunk size)

Requirements

  

If no flags are set, the system will return the best available memory block. (MEMF_*)

Function result

A pointer to the newly allocated memory block. If there are no free memory regions large enough to satisfy the request, nil will be returned. The pointer must be checked for nil before the memory block may be used!

Description

This is the memory allocator to be used by system code and applications. It provides a means of specifying that the allocation should be made in a memory area accessible to the chips, or accessible to shared system code.

Memory is allocated based on requirements and options. Any "requirement" must be met by a memory allocation, any "option" will be applied to the block regardless. AllocMem will try all memory spaces until one is found with the proper requirements and room for the memory request.

Errors

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

This function may not be called from interrupts.

A DOS process will have its pr_Result2 field set to ERROR_NO_FREE_STORE if the memory allocation fails.

See also

Exec.ExecFreeMem

  

Free a memory block with given size

AllocVec

  

Allocate memory and keep track of the size


Documentation generated on: 2021-07-30