Re: [R-pkg-devel] [External] Re: Replacement for SETLENGTH

2025-01-16 Thread Luke Tierney via R-package-devel
You may be over-complicating this. Taking mcmc_new in src/lm_lcmc.c from https://github.com/merliseclyde/BAS, to minimize code changes I would arrange the memory management along these lines: SEXP mcmc_new(...) { /* ... */ /* create and protect ANS */ SEXP ANS = PROTECT(allocVector(V

Re: [R-pkg-devel] [External] Re: Replacement for SETLENGTH

2025-01-15 Thread Merlise Clyde, Ph.D.
Thanks Luke ! I had seen the usage and discussion of growable vectors, as well as using SET_TRUELENGTH with SETLENGTH and didn't necessarily want to get even more out of API compliance :-). but if that looks like it will allowed (subject to perhaps changes) that seems like the better way forw

Re: [R-pkg-devel] [External] Re: Replacement for SETLENGTH

2025-01-15 Thread Luke Tierney via R-package-devel
On Wed, 15 Jan 2025, Iris Simmons wrote: I don't think memcpy works well for VECSXP. The elements being overwritten need to have their reference counts decreased and the new elements need to have theirs increased. You do not want to use memcpy or inanyother way try to write to the locations in