Skip to content
Back to formatted view

Raw Message

Message-ID: <20025.22442.981794.885500@max.nulle.part>
Date: 2011-08-03T14:14:02Z
From: Dirk Eddelbuettel
Subject: [Rcpp-devel] Pointer troubles
In-Reply-To: <CAK0yx2c5Egwv=g8Vz4Q6HYjXbXTZkwwzhQorNqbkUseRt2ZjaA@mail.gmail.com>

On 3 August 2011 at 15:44, Willem Ligtenberg wrote:
| Hi Dirk,
| 
| Won't test be cleared up when the garbage collector calls
| intObjFinalizer(PointerTotest)? That is what I thought the finalizer
| would do.
| Is there a specific chapter about the mixing of new/delete and the R
| allocations?

It may have been in Section 6.1 about 'Memory allocation' but I don't see it
right now.  I may have misremembered the recommendation about new/delete with
the one for malloc/free: most of the time you are better off using the R
facilities as you fall back onto R's error handling.

And in general, you should not need new / delete. Modern C++ uses STL
containers which hide all this, and Rcpp conveniently wraps that for you --
just like Romain just showed you the simpler XPtr use.

Dirk

-- 
Gauss once played himself in a zero-sum game and won $50.
                      -- #11 at http://www.gaussfacts.com