MALLOC

Elemental Intrinsic Function (Specific): Allocates a block of memory. This is a specific function that has no generic function associated with it. It must not be passed as an actual argument.

Syntax

result = MALLOC (i)

i
(Input) Must be of type integer. This value is the size (in bytes) of memory to be allocated.

Results:

The result is of type INTEGER(4) on on ia32 processors; INTEGER(8) on Alpha and ia64 processors. The result is the starting address of the allocated memory. The memory allocated can be freed by using the FREE intrinsic function.

Compatibility

CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB

Example

  INTEGER(4) SIZE
  REAL(4) STORAGE(*)
  POINTER (ADDR, STORAGE)     ! ADDR will point to STORAGE
  SIZE = 1024                 ! Size in bytes
  ADDR = MALLOC(SIZE)         ! Allocate the memory
  CALL FREE(ADDR)             ! Free it
  END