[R] When exactly do I need R_alloc when using the .Call() interface?

michael.zombok at googlemail.com michael.zombok at googlemail.com
Wed Dec 21 17:34:46 CET 2011


Hi,

I am trying to implement an algorithm in C which will be called via the
.Call() interface.

While reading the 'Writing R Extension' manual, I stumbled upon the
R_alloc() function for allocating storage for C objects. The manual says
it should be used to allocate storage if an C object is needed/created
while manipulating R objects within a function called via the .Call()
interface. 

Because none of the examples in the manual uses R_alloc(), I wonder when
it is needed? If I create an pointer in C or a single variable it seems
not necessary?! (Or at least it is never called in the examples.). Is it
necessary when creating an array? Or better when exactly should I use
R_alloc?

Thanks!

Best regards,
Michael



More information about the R-help mailing list