Dear all, does anybody know if there is a way to implement the following idea: if for example I have a C/C++ structure of form: struct { int size; char * data; } SData; in C code I could create some implementation that would create this structure by pointer and fill in the data, so I would have a variable something like SData* myData; Now what I need is to pass this data to a certain SEXP structure and keep it completely in R, thus setting myData = NULL and _unloading the C library_; then later I want to create another variable, in another C call, SData* myOldData and reload it with values from R. Is there a way to do that, keeping also in mind that char* data is generally binary data. Would be greatful for any suggestions. Regards Oleg
Huntsinger, Reid
2005-Feb-04 17:46 UTC
[Rd] RE: [R] Keeping the data of C structure in R variables?..
I think you should have a look at external pointers (type EXTPTRSXP). They are used in the R source . See, for example, memory.c. Also see the developer page notes on weak references, finalizers, etc, which you'll need to be familiar with. This is really an R-devel question! Reid Huntsinger -----Original Message----- From: r-help-bounces@stat.math.ethz.ch [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Oleg Sklyar Sent: Friday, February 04, 2005 11:11 AM To: R-help@stat.math.ethz.ch Subject: [R] Keeping the data of C structure in R variables?.. Dear all, does anybody know if there is a way to implement the following idea: if for example I have a C/C++ structure of form: struct { int size; char * data; } SData; in C code I could create some implementation that would create this structure by pointer and fill in the data, so I would have a variable something like SData* myData; Now what I need is to pass this data to a certain SEXP structure and keep it completely in R, thus setting myData = NULL and _unloading the C library_; then later I want to create another variable, in another C call, SData* myOldData and reload it with values from R. Is there a way to do that, keeping also in mind that char* data is generally binary data. Would be greatful for any suggestions. Regards Oleg ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html