char *S_alloc(nelem, elsize) long nelem; int elsize;
sizeof
;
e.g.,
sizeof(double)
.
(char *)
pointer to a dynamically
allocated block of memory suitable to hold the number of elements
of the type specified.
This storage is associated with the S-PLUS frame in which the
S_alloc
invocation occurred
and disappears when that frame is completed.
Hence, you should never explicitly try to free space allocated in this way.
In C code being called from S-PLUS,
dynamic storage allocation should generally use
S_alloc
,
instead of the standard C function calloc.
It differs from calloc in that storage allocated this way
is automatically freed by S-PLUS at the appropriate time.
You are free to use calloc as well,
but it is only appropriate if you want the storage
to last throughout the S-PLUS session,
or if you will free it yourself later on.
The function allocates (and fills with 0s) enough space for an array of
nelem
items,
each taking up
elsize
bytes.
The storage it allocates will last until the current evaluation frame
goes away
(at the end of the function calling
.C
).