PSX_CALLOC

Allocate space for several objects of specified type

Description:

The routine allocates an amount of virtual memory specified by NMEMB and TYPE. The number of bytes allocated is equal to the number of bytes required to store a single variable of type TYPE, multiplied by NMEMB. A pointer to the allocated storage is returned in PNTR. This pointer can be passed on to other subroutines using the %VAL construct. If the storage cannot be allocated, then PNTR is set to zero, STATUS is set to PSX__NOALL and an error is reported.

Invocation

CALL PSX_CALLOC( NMEMB, TYPE, PNTR, STATUS )

Arguments

NMEMB = INTEGER (Given)
The number of locations of TYPE required. If the number required exceeds the maximum that can be stored in an INTEGER (about 2.1E9), them routine PSX_CALLOC8 should be used in place of PSX_CALLOC. PSX_CALLOC8 has an identical interface except that the NMEMB argument is an INTEGER∗8.
TYPE = CHARACTER ∗ ( ∗ ) (Given)
The type of each location
PNTR = POINTER (Returned)
A pointer to the allocated storage.
STATUS = INTEGER (Given and Returned)
The global status.

Examples:

CALL PSX_CALLOC( 20, ’_INTEGER’, PNTR, STATUS )
CALL SUB1( %VAL(PNTR), 20, STATUS )
...
SUBROUTINE SUB1( ARRAY, N, STATUS )
INTEGER N
INTEGER ARRAY( N )
...
Generates storage for an array.

The call to PSX_CALLOC allocates storage for a 20 element array of type INTEGER. 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.

Notes:

External Routines Used

cnf: cnf Calloc, cnfFptr, cnfImpn

References

Copyright

Copyright (C) 1991 Science & Engineering Research Council