ALLOCMEM

Top  Previous  Next

Syntax

INT = ALLOCMEM(mem as MEMORY, count as INT, size as INT)

Description

Allocates memory for use within your program. Memory must be freed with the FREEMEM command when your program is finished using it. Total memory size will be equal to count * size. All bytes of the block of memory are initialized to zero.

Parameters

mem - A variable of type MEMORY used as a placeholder to access the allocated memory

count - The number of elements to allocate

size - The size of each element

Return value

Returns 0 on success or -1 on failure. Function may fail if the size requested is larger than the amount of free memory available.

Remarks

See also FREEMEM, READMEM, WRITEMEM

Example usage

DEF mymem as MEMORY
IF ALLOCMEM(mymem,100,10)
    PRINT "Allocated 1000 bytes of memory"
    FREEMEM mymem
ENDIF