Skip to content
Prev 183 / 63424 Next

R-alpha: S_alloc

Kurt Hornik wrote:
I believe it allocates zero'd memory like calloc but S is responsible
for freeing it (calling free on it probably has "unpredictable results
..."). S probably usually frees the memry on return from the function
call that got you into C code. In old versions of S I think this was
managed by saving/ resetting the sbrk on function entry/exit and
allocating above the current sbrk value. THis way memory used in a
function was recovered just by restoring the sbrk -- a nice
stack-based discipline. I think the current strategy is a bit
different both to allow portability and to improve memory recovery
during a function call. As a rasult, memory allocated may not be freed
right after the outer call returns, but since S doesn't have a garbage
collector as such it probably has to happen pretty soon after the
return.
Message-ID: <9705201738.AA09065@nokomis.stat.umn.edu>
In-Reply-To: <199705201625.SAA27815@aragorn.ci.tuwien.ac.at> from "Kurt Hornik" at May 20, 97 06:25:41 pm