Re: [Rd] Truncating vectors by reference in C-backend

2017-11-21 Thread luke-tierney
DO NOT DO THIS!!! SETLENGTH and SET_TRUELENGTH are NOT part of the API and are for internal use only. Tho proper way to do this is to copy the data you want into a smaller vector and allow the larger one to be garbage collected. [VECSXPs are like all other vectors in that they are contigously al

[Rd] Truncating vectors by reference in C-backend

2017-11-21 Thread mbonsch
Dear all, I want to create a function shrinkVector(x) that takes x and truncates it to the first element without copy. With SETLENGTH and SET_TRUELENGTH, I can achieve that. You can find a reproducible example below. But the memory that was freed is not available for other objects afterwards,