next up previous 216
Next: PSX_CTIME - Convert the calendar time to a character string
Up: Routine Descriptions
Previous: PSX_ASCTIME - Convert a time structure to a character string


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
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


next up previous 216
Next: PSX_CTIME - Convert the calendar time to a character string
Up: Routine Descriptions
Previous: PSX_ASCTIME - Convert a time structure to a character string

PSX POSIX interface routines
Starlink User Note 121
P M Allan
A J Chipperfield
10 April 2003
E-mail:ussc@star.rl.ac.uk

Copyright © 2000 Council for the Central Laboratory of the Research Councils