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

2012-03-18 Thread oliver
On Sat, Mar 17, 2012 at 11:47:24PM -0400, Simon Urbanek wrote: [...] > You can always define Strdup() since strdup() is just a shorthand for > malloc()+strcpy() -- in fact in R it's easier since Calloc will never return > NULL so trivially > #define Strdup(X) strcpy(Calloc(strlen(X)+1, char), X) [.

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

2012-03-18 Thread Dirk Eddelbuettel
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 s

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

2012-03-17 Thread oliver
On Sat, Mar 17, 2012 at 10:08:05PM -0500, Dirk Eddelbuettel wrote: > > On 18 March 2012 at 03:30, oliver wrote: > | Hello, > | > | when looking at "Writing R Extensions" > | with mem-allocation in mind, I wondered, > | which functions to use to substitute > | malloc(), calloc(), realloc() and str

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

2012-03-17 Thread Simon Urbanek
On Mar 17, 2012, at 10:30 PM, oliver wrote: > Hello, > > when looking at "Writing R Extensions" > with mem-allocation in mind, I wondered, > which functions to use to substitute > malloc(), calloc(), realloc() and strdup() and free(). > > It looked like Calloc() or R_Calloc() might be useful fo

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

2012-03-17 Thread Dirk Eddelbuettel
On 18 March 2012 at 03:30, oliver wrote: | Hello, | | when looking at "Writing R Extensions" | with mem-allocation in mind, I wondered, | which functions to use to substitute | malloc(), calloc(), realloc() and strdup() and free(). | | It looked like Calloc() or R_Calloc() might be useful for |