From edd at debian.org  Sun Mar 18 14:19:06 2012
From: edd at debian.org (Dirk Eddelbuettel)
Date: Sun, 18 Mar 2012 08:19:06 -0500
Subject: [Rd] malloc/calloc/strdup and R's aequivalents
In-Reply-To: <20120318051611.GA20315@siouxsie>
References: <20120318023052.GB13699@siouxsie>
	<20325.20885.364933.666819@max.nulle.part>
	<20120318051611.GA20315@siouxsie>
Message-ID: <20325.57546.463137.441482@max.nulle.part>


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.

Dirk

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



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