[R] S_alloc or Calloc for return value

Dan Kelley kelley.dan at gmail.com
Tue Jul 21 15:56:28 CEST 2009


I'm afraid I am missing something.  In my R function (call it "foo", say) I
am doing something like 

     foo <- function() {
        ...
        .C("bar", ..., res=integer(n), ...)$res
    }

but I don't know the "n" to use; that is determined inside my C function
"bar".  Is there a way around this?  

I'm sorry to be thick on this.  Too many decades of C have made me love
pointers too much, I reckon.




Dirk Eddelbuettel wrote:
> 
> 
> You want R_alloc(). Here, "end of the call" is the call of the R function
> that calls your C function. This is what you want---the data will be
> available for the caller of your C code.
> 
> 

-- 
View this message in context: http://www.nabble.com/S_alloc-or-Calloc-for-return-value-tp24579062p24588176.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list