Allocate virtual memory PSX_MALLOC
The call to PSX_MALLOC allocates forty bytes of storage. The pointer to this storage is then passed to subroutine SUB1, where it is accessed as an array of INTEGERs. We assume SUB1 returns without action if STATUS is bad.
Note that in this case the program needs to know that an INTEGER variable is stored in four bytes. This is not portable. In such a case it is better to use PSX_CALLOC or to use the symbolic constants NUM_NBT defined in the file PRM_PAR to determine the number of bytes per unit of storage. (See SUN/39 for a description of these constants).
Storage allocated by PSX_MALLOC should be returned by a call to PSX_FREE when it is no longer needed.
PNTR is declared to be of type POINTER. This is usually represented in FORTRAN as an INTEGER, although any type that uses the same amount of storage would be just as good. The pointer will have been registered for C and FORTRAN use according to the scheme described in SUN/209, allowing its use where pointers are longer than INTEGERs. For portability, the construct %VAL(CNF_PVAL(PNTR)), rather than simply %VAL(PNTR), should be used to pass the pointer to the subroutine. Function CNF_PVAL is described in SUN/209 Section ‘Pointers’.
If several calls to PSX_MALLOC are made, the space returned by each call is completely separate from that made by any other call. In particular, the program should not assume that the space returned by successive calls is contiguous.
POSIX standard (1988), section 8.1
ANSI C standard (1989), section 4.10.3.3