.BG
.FN S_alloc
.TL
Storage Allocation in C
.CS
char *S_alloc(nelem, elsize)
unsigned nelem, elsize;
.AG nelem
how many elements of storage to allocate.
.AG elsize
the size in bytes of each element; typically
some C expression in involving `sizeof'; e.g., `sizeof(double)'.
.RT
A `(char *)' pointer to a dynamically allocated block of memory suitable
to hold the number of elements and type specified.
This storage is associated with the S frame in which the `S_alloc'
invocation occurred and disappears when that frame is completed.
.PP
In
.I any
C code being called from S, dynamic storage allocation should generally
use
`S_alloc',
.Ix storage allocation in C
instead of the standard C function
.Co calloc .
It differs from
.Co calloc
in that storage allocated this way is automatically freed by S at the
appropriate time.
You are free to use
.Co calloc
as well, but it is only appropriate if you want the storage to last
throughout the S session, or if you will free it yourself later on.
.KW programming
.WR
