malloc(3F)
NAME
malloc, free, realloc, calloc − memory allocator, Fortran interface
SYNOPSIS
integer∗4 function malloc (size)
integer∗4 size
subroutine free (ptr)
integer∗4 ptr
integer∗4 function realloc (ptr, size)
integer∗4 ptr, size
integer∗4 function calloc (nelem, elemsize)
integer∗4 nelem, elemsize
DESCRIPTION
malloc, free, realloc and calloc provide a Fortran-callable interface to the memory management routines described in malloc(3C).
malloc returns the address of a block of memory at least size bytes beginning on a word boundary. As there is no explicit "pointer" type in Fortran, addresses are handled as INTEGER∗4 values.
free deallocates the block of memory at address ptr previously allocated by malloc. This space is returned to the available memory pool.
realloc changes the size of the block of memory at address ptr to size bytes and returns the (possibly changed) address of the block. The contents of the block will be unchanged up to the lesser of the new and old sizes.
calloc allocates space for an array of nelem elements of size elemsize. The space is initialized to zeros.
The Hf77 POINTER statement declares a block of variables which are accessed relative to the memory address held in an INTEGER∗4 variable. Space for the block must be allocated prior to using a based variable. The sizeofblock(3f) intrinsic returns the size of a pointer block in bytes, making it a natural choice for use in allocation requests.
pointer /ptr/ a, b, c
integer∗4 ptr, a, b, c
external malloc
integer∗4 malloc
ptr = malloc (sizeofblock (ptr))
...
call free (ptr)
DIAGNOSTICS
malloc, realloc and calloc return 0 if there is no available memory or if an error has been detected.
FILES
/usr/lib/libhU77.a
SEE ALSO
malloc(3C), sizeofblock(3f), CX/UX Hf77 Fortran Reference Manual.
NOTES
When compiling source with the -Qocs option, an explicit underscore needs to be added to the end of the routine names.
CX/UX Hf77 Fortran Reference Manual