Displaying 1 result from an estimated 1 matches for "set_truelength".
2017 Nov 21
1
Truncating vectors by reference in C-backend
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, except if x is a list (VECSXP). Any suggestions?
library(inline)
## define the shrinking function
shrinkVector <- cfunction(signature(x = "ANY&quo...