[R] S_alloc or Calloc for return value
Dan Kelley
kelley.dan at gmail.com
Tue Jul 21 01:06:04 CEST 2009
I am trying to write a C function to create a vector of integers that can be
used by the R calling function. I do not know the size of the vector in the
R calling function. (Well, actually, I have an upper limit on the size, but
that is so large that R cannot allocate it. What I'm doing in the function
is to do a sieving procedure, and the result will be small enough to fit
into my machine's memory.)
My reading of sections 6.1.1 and 6.1.2 of the guide on writing R extensions
has left me a bit confused. Under R_alloc, I read "R will reclaim the
memory at the end of the call" which seems to suggest the storage won't be
made available afterwards, so that's not what I should use. As for the
alterntaive, under Calloc, I read "This memory lasts until freed by the
user", and it's clear that this is to be done within the C function in
question.
Summary question: how can I allocate memory withing a C function, making it
available to an R function that calls the C function?
Thanks. Dan.
--
View this message in context: http://www.nabble.com/S_alloc-or-Calloc-for-return-value-tp24579062p24579062.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list