Re: [Rd] Transferring ownership of R-managed buffer

2017-03-30 Thread Tim Keitt
On Thu, Mar 30, 2017 at 3:15 PM, Gabriel Becker wrote: > technically possible So the garbage collector knows the buffer length independently of the SEXPREC length field? Then, yes, its doable, but as you say not advisable. THK http://www.keittlab.org/ [[alternative HTML version delet

Re: [Rd] Transferring ownership of R-managed buffer

2017-03-30 Thread Gabriel Becker
On Thu, Mar 30, 2017 at 11:52 AM, Tim Keitt wrote: > > On Wed, Mar 29, 2017 at 4:56 PM, Gabriel Becker > wrote: > >> The concept of having a vector which is a "window" into another vector >> without duplication ( which I suspect is at least related to your use-case, >> though I could be wrong) i

Re: [Rd] Transferring ownership of R-managed buffer

2017-03-30 Thread Tim Keitt
On Wed, Mar 29, 2017 at 4:56 PM, Gabriel Becker wrote: > The concept of having a vector which is a "window" into another vector > without duplication ( which I suspect is at least related to your use-case, > though I could be wrong) is a special case of one of alt-representations I > have implem

Re: [Rd] Transferring ownership of R-managed buffer

2017-03-29 Thread Gabriel Becker
Tim, What you're describing is a special case of the ALTREP framework/API that Luke Tierney, Tomas Kalibera, and I are working on putting into R. See my initial proposal to the DSC here: https://www.r-project.org/dsc/2016/slides/customvectors.html and the subsequent branch here: https://svn.r-proj

Re: [Rd] Transferring ownership of R-managed buffer

2017-03-29 Thread Tim Keitt
http://www.keittlab.org/ On Wed, Mar 29, 2017 at 1:04 PM, Hervé Pagès wrote: > Hi Tim, > > On 03/29/2017 08:24 AM, Tim Keitt wrote: > >> 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. >> > > What to you me

Re: [Rd] Transferring ownership of R-managed buffer

2017-03-29 Thread Hervé Pagès
On 03/29/2017 11:04 AM, Hervé Pagès wrote: Hi Tim, On 03/29/2017 08:24 AM, Tim Keitt wrote: 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. What to you mean exactly by "an existing buffer managed by R"? I

Re: [Rd] Transferring ownership of R-managed buffer

2017-03-29 Thread Hervé Pagès
Hi Tim, On 03/29/2017 08:24 AM, Tim Keitt wrote: 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. What to you mean exactly by "an existing buffer managed by R"? If I have something like: void *p = (void*)

[Rd] Transferring ownership of R-managed buffer

2017-03-29 Thread Tim Keitt
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); // I