Kurt Hornik wrote:>
> Does anyone know what exactly S_alloc() does? (Yes, it's porting time
> again ...)
>
> Thanks,
> -k
>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> r-devel mailing list -- Read
http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To:
r-devel-request@stat.math.ethz.ch
>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>
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.
--
Luke Tierney
University of Minnesota Phone: 612-625-7843
School of Statistics Fax: 612-624-8868
206 Church Street email: luke@stat.umn.edu
Minneapolis, MN 55455 USA WWW: http://www.stat.umn.edu
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To:
r-devel-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-