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 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