.\" Copyright (c) 1985 Regents of the University of California.
.\" All rights reserved. The Berkeley software License Agreement
.\" specifies the terms and conditions for redistribution.
.\" @(#)malloc.3f 6.1 (Berkeley) 5/15/85
.TH MALLOC 3F "May 15, 1985"
malloc, free, falloc \- memory allocator
.B subroutine malloc (size, addr)
.B subroutine free (addr)
subroutine falloc (nelem, elsize, clean, basevec, addr, offset)
integer nelem, elsize, clean, addr, offset
provide a general-purpose memory allocation package.
the address of a block of at least
bytes beginning on an even-byte boundary.
allocates space for an array of
and returns the address of the block in
an index such that the storage may be addressed as
.I basevec(offset+1) ... basevec(offset+nelem).
gets extra bytes so that after address arithmetic,
all the objects so addressed are within the block.
is the address of a block previously allocated by
this space is made available for further allocation,
but its contents are left undisturbed.
To free blocks allocated by
Needless to say, grave disorder will result if the space assigned by
is overrun or if some random number is handed to
to 0 if there is no available memory or if the arena
has been detectably corrupted by storing outside the bounds of a block.
The following example shows how to obtain memory and use it within a
integer addr, work(1), offset
call falloc ( n, 4, 0, work, addr, offset )
The next example reads in dimension information,
allocates space for two arrays and two vectors,
integer addr, dummy(1), offs
call falloc ( indtot, 4, 0, dummy, addr, offs )
call doit( dummy(indm1+offs), dummy(indm2+offs),
. dummy(indm3+offs), dummy(indsym+offs),
. dummy(indv +offs), m, n, lsym )
subroutine doit( arr1, arr2, arr3, vsym, vec, m, n, lsym )
real arr1(k,l), arr2(l,m), arr3(k,m), vsym(lsym), v2(m)