[Rd] malloc/calloc/strdup and R's aequivalents

Dirk Eddelbuettel edd at debian.org
Sun Mar 18 14:19:06 CET 2012

On 18 March 2012 at 06:16, oliver wrote:
| > R> library(inline)
| > R> 
| > R> f <- cfunction(signature(), verbose=TRUE, body='
| > +    double *p = Calloc(5, double);
| [...]
| That line cleared the issue.
| Thank you for providing an example.
| When reading in the documentation I was not sure,
| how to interpret "type" in setion 6.1.2.
| It was meant as the name of the type, and that's, why my
| sizeof() stuff created the problem.
| I tried around and then saw, that the name of the type
| is accepted, not only with typical base-types of C, but
| it also eats the names of my structs/typedefed structs.

Understandable, the manual is not toi clear there.  The easiest answer, in
such cases, is IMHO provided by other source packages.

Too bad the Google Code Search is now defunct.  But besides a recursive grep
in R's src/ directory, a simple Google search for "site:r-project.org Calloc"
also brings the solution up rightaway.


"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
dark to read." -- Groucho Marx

More information about the R-devel mailing list