Skip to content
Prev 13466 / 398502 Next

not safe to return vector pointer

On Mon, 10 Sep 2001, Chris Jeffery wrote:

            
If it was recent, it would have been better to update to R-1.3.0 or 1.3.1
The new memory manager in R 1.2 needs to know when objects are updated.
This means that there are new macros for access to strings and vectors.

You need to use eg

  SET_VECTOR_ELT(rlist,0,NEW_INTEGER(1));

instead of

  VECTOR(rlist)[0]=NEW_INTEGER(1));.

There are similar macros for string access.

More detail is given in the 'Writing R Extensions' manual. Modifying code
to handle this new `write barrier' isn't that painful and the new memory
manager is much better than the old one, so it was worth the change.


	-thomas

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._