From tkeitt at utexas.edu  Wed Mar 29 17:24:18 2017
From: tkeitt at utexas.edu (Tim Keitt)
Date: Wed, 29 Mar 2017 10:24:18 -0500
Subject: [Rd] Transferring ownership of R-managed buffer
Message-ID: <CANnL8go0rb+01wbPzygrFO+rEznLsT1K+_buZEzAhAMecNP8RQ@mail.gmail.com>

I have a use case where I would like to create an SEXP around an existing
buffer that is managed by R, thus avoiding a copy operation. If I have
something like:

void *p = (void*) RAW(PROTECT(Rf_allocVector(RAWSXP, n)));
... additional maniupulation ...
SEXP x = somefunc(SXPTYPE, n, p);  // ????

Is there a "placement" constructor available? (I have arranged for the
corresponding UNPROTECT.) I've looked at and experimented with R_allocator
and allocVector3, but can't quite get it right. I know this is odd, but it
makes sense for my use case.

Thanks for any pointers.

THK

http://www.keittlab.org/

	[[alternative HTML version deleted]]



[Rd] Transferring ownership of R-managed buffer
Tim Keitt