On 8/2/2006 11:08 AM, Tamas K Papp wrote: > Hi, > > I have a C function (called via .C) which returns (by writing into > buffers) some values of known (or fixed) length, all of these are > numerical so I can allocate storage for them via as.double() and > as.integer(). > > However, there is a potential error message that I would like to > return into a char * buffer [1]. How can I allocate it in R (eg > something similar to as.integer(), but taking the number of > characters). > > I would like to avoid .Call if possible, this is the only tricky > argument. > > Thanks, > > Tamas > > [1] I would of course use strncpy to avoid overflows.
If you are unsure of the length of the message that you want to return, you can use R_alloc in C to allocate a buffer, and you don't need to worry about disposing of it: it will be garbage collected. Duncan Murdoch ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel