[Rd] external pointers

From: Ross Boylan <ross_at_biostat.ucsf.edu>
Date: Fri 09 Dec 2005 - 23:04:28 GMT


I have some C data I want to pass back to R opaquely, and then back to C. I understand external pointers are the way to do so.

I'm trying to find how they interact with garbage collection and object lifetime, and what I need to do so that the memory lives until the calling R process ends.

Could anyone give me some pointers? I haven't found much documentation. An earlier message suggested looking at simpleref.nw, but I can't find that file.

So the overall pattern, from R, would look like opaque <- setup(arg1, arg2, ....) # setup calls a C fn docompute(arg1, argb, opaque) # many times. docompute also calls C
# and then when I return opaque and the memory it's wrapping get
#cleaned up. If necessary I could do

teardown(opaque) # at the end

"C" is actually C++ via a C interface, if that matters. In particular, the memory allocated will likely be from the C++ run-time, and needs C++ destructors.

-- 
Ross Boylan                                      wk:  (415) 514-8146
185 Berry St #5700                               ross@biostat.ucsf.edu
Dept of Epidemiology and Biostatistics           fax: (415) 514-8150
University of California, San Francisco
San Francisco, CA 94107-1739                     hm:  (415) 550-1062

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Sat Dec 10 10:09:41 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:34 GMT