Skip to content
Prev 61639 / 63421 Next

Heap access across multiple calls from R to C++

On Wed, 24 May 2023 02:08:25 +0200
<pikappa.devel at gmail.com> wrote:

            
The .Call() interface (where functions take an arbitrary number of
native R objects and return a native R object) combined with external
pointers is likely to be a better approach here:

https://cran.r-project.org/doc/manuals/R-exts.html#External-pointers-and-weak-references

On the R side, the returned SEXP will have class 'externalptr', with
not much to do about it programmatically. C code can additionally
register a finalizer on the object in order to release the memory
automatically after the it is discarded.