C function for memory allocation in S-PLUS functions.
USAGE:
char *S_alloc(nelem, elsize)
long nelem; int elsize;
REQUIRED ARGUMENTS:
nelem:
how many elements of storage to allocate.
elsize:
the size in bytes of each element; typically
some C expression involving sizeof; e.g., sizeof(double).
VALUE:
A (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.
NOTE:
In C code being called from S-PLUS, dynamic storage
allocation should generally use S_alloc,
instead of the standard C function
It differs from
in that storage allocated this way is automatically freed by S-PLUS at the
appropriate time.
You are free to use
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.
DETAILS:
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) or until memory compaction in an S-PLUS loop reclaims it.